Objective 2.0 properties
Objective 2.0 properties
- Subject: Objective 2.0 properties
- From: "Ignacio Enriquez" <email@hidden>
- Date: Fri, 17 Oct 2008 11:19:50 +0900
hi everyone!
I have a problem that is taking me hours of debbuging time. So I
decided to learn the origin of the problem.
It's about properties (Objective C 2.0)
As you know there are some kinds of properties (nonatomic,
retain,asign, readonly, readwrite... etc)
Let's thinks the next case :
@interface Lesson : NSObject {
NSString *lessonTitle;
NSDate *referDate;
NSNumber *lessonDuration;
}
@property (nonatomic, retain) NSString* lessonTitle;
@property (nonatomic, retain) NSDate *referDate;
@property (assign) NSNumber * lessonDuration;
@property (readonly) UIImage * lessonImage;
@end
@implemetantion Lesson
@synthesize lessonTitle;
@synthesize referDate;
@synthesize lessonDuration;
-(UIImage *) lessonImage{
return [UIImage imageNamed:
[NSString stringWithFormat:@"cellImage%@",self.lessonTitle]]; //is self. ok?
}
@end
So the question is
Inside Lesson.m when i want to call or refer lessonTitle what is the best?
self.lessonTitle or just only lessonTitle? (note that is nonatomic, retain))
the same
Inside Lesson.m when I want to call or refer lessonDuration, What is
the best? self.lessonDuration or just lessonDuration (note that is
assign)
the same
Inside Lesson.m when I want to call or refer lessonImage what is the best?
self.lessonImage or just lessonImage? (note that is readonly)
I have been trying a lot of conbination and none of them result in
compilation errors, but when I run the application it crashes.!
So I would like to know the difference between self.property and just property
I would appreciate your really kind explanation.
Thanks.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden