Why zone is always nil while implementing NSCopying?

前端 未结 5 1413
慢半拍i
慢半拍i 2021-02-13 04:47

It may be simple question, but why implementing NSCopying protocol in my class, I get zone == nil

- (id)copyWithZone:(NSZone *)zone
{
    if (zo         


        
5条回答
  •  抹茶落季
    2021-02-13 05:15

    Zone is a legacy from the old days when computers had 8 megs or less of RAM.

    Check this out (3.1.2 Memory Allocation and Zones):

    http://www.gnustep.org/resources/documentation/Developer/Base/ProgrammingManual/manual_3.html

    There is also a good discussion of this over on cocoa builder (well it was on the cocoa dev mailing list) from about 10 years ago. This is exactly what @bbum was saying.

    http://www.cocoabuilder.com/archive/cocoa/65056-what-an-nszone.html

    Apparently this used to be documented in the Apple docs, but it was changed at some point since 2007-06-06.

    http://www.cocoadev.com/index.pl?NSZone

提交回复
热议问题