Problem
I am trying to create an object in Objective-C. I know how to do it but I have a few questions regarding the methods in the implementation file.
The Object:
@interface Program : NSObject {
NSString *sid;
NSString *le;
NSString *sd;
NSString *pid;
NSString *n;
NSString *d;
NSString *url;
}
@property (nonatomic, retain) NSString *sid;
@property (nonatomic, retain) NSString *le;
@property (nonatomic, retain) NSString *sd;
@property (nonatomic, retain) NSString *pid;
@property (nonatomic, retain) NSString *n;
@property (nonatomic, retain) NSString *d;
@property (nonatomic, retain) NSString *url;
@end
Question
I should only implement dealloc and init.. Am I right on this?
Furthermore, I have no special initializations, so should I keep the default init method as follows?
- (id)init
{
self = [super init];
if (self) {
// Initialization code here.
}
return self;
}
retainthe NSStrings? If a retained object is actually an NSMutableString, it can change from under you. I find it rare toretainNSString properties; I usuallycopythem.