Apple headers contain several categories

When I look at some Apple header files, I notice that they declare multiple interfaces using categories for the same object.

For instance: NSDictionary.h

@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>

//methods

@end

@interface NSDictionary (NSExtendedDictionary)

//methods

@end

@interface NSDictionary (NSDictionaryCreation)

//methods

@end

Is this just a way to help organize code? As a user, there is no difference, all methods in all categories appear when using NSDictionary.

Is there any other useful result?

+3
source share
2 answers

nielsbot has the right idea, but there is a definite technical reason for the categories. You can put implementations in separate files. (Well, different translation units are technically speaking.)

File 1:

@implementation NSDictionary
...
@end

File 2:

@implementation NSDictionary (NSExtendedDictionary)
...
@end

File 3:

@implementation NSDictionary (NSDictionaryCreation)
...
@end
+6
source

, . . (, , )

EDIT: . , , :

Objective-C . , . Objective-C Smalltalk, . [9]

http://en.wikipedia.org/wiki/Objective-C#Categories

, , NeXT - , .

+3

All Articles