Reputation: 4166
For example I was looking at CHMutableDictionary.h
@interface CHMutableDictionary : NSMutableDictionary {
CFMutableDictionaryRef dictionary; // A Core Foundation dictionary.
}
- (id) initWithCapacity:(NSUInteger)numItems;
- (NSUInteger) count;
- (NSEnumerator*) keyEnumerator;
- (id) objectForKey:(id)aKey;
- (void) removeAllObjects;
- (void) removeObjectForKey:(id)aKey;
- (void) setObject:(id)anObject forKey:(id)aKey;
@end
And it curly brackets CFMutableDictionaryRef dictionary
. But in the Objective-C guide Properties Control Access to an Object’s Values it doesn't make any mention of using {}
in interfaces
@interface Person : NSObject
@property NSString *firstName;
@property NSString *lastName;
@end
So I was just wondering what variables defined in {}
in interfaces of .h
files mean.
Upvotes: 0
Views: 164
Reputation: 318804
You declare instance variables inside the curly braces.
But it's bad form to put them in the .h file. Instance variables should be private, not public. So they do not belong in the public .h file.
There is lots of old Objective-C code that doesn't follow these more modern conventions. Don't write new code using those very outdated conventions.
See https://stackoverflow.com/a/13263345/1226963 for some modern examples.
Upvotes: 4