I just learned about @property and @synthesize. Cool stuff. But I'm a little confused on a few things as far as how to implement my class.
Is this code correct/ideal?
First question: should age be an int? Or NSNumber? Or NSNumber*? Or NSInteger or NSInteger*? I'm confused about whether NSNumber should be a pointer or not.. after all, it IS an object, and with most of these objects, they're pointers.
Second: is it pretty much a given that the @property option "copy" will be used for NSString* all the time? And "assign" is used for ints and other non-pointers, and "retain" is used for pointers to objects other than NSString? I'm not clear on when to use each one.
Is this code correct/ideal?
Code:
@interface Person : NSObject {
NSString *firstName;
NSString *lastName;
int age;
}
@property (readwrite, copy) NSString *firstName;
@property (readwrite, copy) NSString *lastName;
@property (readwrite, assign) int age;
@end
First question: should age be an int? Or NSNumber? Or NSNumber*? Or NSInteger or NSInteger*? I'm confused about whether NSNumber should be a pointer or not.. after all, it IS an object, and with most of these objects, they're pointers.
Second: is it pretty much a given that the @property option "copy" will be used for NSString* all the time? And "assign" is used for ints and other non-pointers, and "retain" is used for pointers to objects other than NSString? I'm not clear on when to use each one.