Reputation: 627
I understand that methods available for other classes to call should be in the header file..but I'm a little confused when the @property should be in the header file and when it should be in the implementation file.
How do you make that decision, and what difference does it make?
Upvotes: 3
Views: 1535
Reputation: 22245
Any property that you want publicly exposed to the other classes goes in the .h file. The 'private' properties (pun intended) go in the implementation file in a anonymous category or class extension. You might also make the .h version of the property readonly for example, and the .m version readwrite.
@interface CPClassFileName ()
@property (nonatomic, retain) NSString *string;
@end
@implementation
...
@end
Upvotes: 6
Reputation: 2107
You put the @property on the header if you want other classes (or developers) to know that there are accessors to your ivars.
To rephrase : If you want "public" getter / setter you put the @property on the header. If you want them private you put the @property on the .m file.
Upvotes: 0