4 ms·
You're misremembering. Prior to ObjC 2, classes indeed exposed fields. Convention was that you should not touch them and use accessors instead, but they were mo
by wool_gather 8y ago
You're misremembering. Prior to ObjC 2, classes indeed exposed fields. Convention was that you should not touch them and use accessors instead, but they were most definitely there, declared in the `@interface`.
@interface Foo : NSObject
{
NSString * name;
NSInteger count;
}
- (NSString)name;
- (void)setName:(NSString *)newName;
- (NSInteger)count;
@end
(This is still legal, of course, but bad practice now that there's `@property` synthesis as well as ivars being declarable in either an extension or the `@implementation` block.)