Hi all,
I am learning objective-c and Cocoa, but not a newbie to programming. And while I am strolling along in "Cocoa Programming for Mac OS X" and into Chapter 8: NSArrayController. The start of the chapter has you create an application that will be built on in the later chapters.
In the code in the .h file it uses @property. I am using XCode 2.5 on a 10.4.11 system. I get a compile error, which I figure from previous experience and posted a question here, must be an Objective-C 2.0 feature only available on 10.5.
Here is the code in the .h file:
The .m file does not have any methods for what I am assuming are properties for personName and expectedRaise. You would access them by using the dot method (somePerson.personName etc) instead of the normal object method ([somePerson personName]).
My question is how do I implement the functionality of @property in a "normal" non 10.5 way? Would I do it something like this in the header (is a .h file still called a header file?) file:
Then in the .m file I would implement the methods of course (at least I think I would). The second part of my question is in the @property line is what does the 'copy' option do and how do I implement that?
Thank you in advance. I am on an old PowerBook G4 and I am not going to be upgrading either my machine or OS anytime soon. So all of what I am learning must be in XCode 2.5 (the lastest version for 10.4 according to Apple).
Well I must be learning something! I did complete my exercises with the apps working as stated and my machine did not crash.
Thank you again for your help.
-Don
I am learning objective-c and Cocoa, but not a newbie to programming. And while I am strolling along in "Cocoa Programming for Mac OS X" and into Chapter 8: NSArrayController. The start of the chapter has you create an application that will be built on in the later chapters.
In the code in the .h file it uses @property. I am using XCode 2.5 on a 10.4.11 system. I get a compile error, which I figure from previous experience and posted a question here, must be an Objective-C 2.0 feature only available on 10.5.
Here is the code in the .h file:
Code:
@interface Person : NSObject
{
NSString *person;
float expectedRaise;
}
@property (readwrite, copy) NSString *personName;
@property (readwrite) float expectedRaise;
@end
The .m file does not have any methods for what I am assuming are properties for personName and expectedRaise. You would access them by using the dot method (somePerson.personName etc) instead of the normal object method ([somePerson personName]).
My question is how do I implement the functionality of @property in a "normal" non 10.5 way? Would I do it something like this in the header (is a .h file still called a header file?) file:
Code:
@interface Person : NSObject
{
NSString *person;
float expectedRaise;
}
- (NSString *)personName;
- (void)setPersonName:(NSString *)thePersonName;
- (float) expectedRaise;
- (void)setExpectedRaise:(float)theExpectedRaise;
@end
Then in the .m file I would implement the methods of course (at least I think I would). The second part of my question is in the @property line is what does the 'copy' option do and how do I implement that?
Thank you in advance. I am on an old PowerBook G4 and I am not going to be upgrading either my machine or OS anytime soon. So all of what I am learning must be in XCode 2.5 (the lastest version for 10.4 according to Apple).
Well I must be learning something! I did complete my exercises with the apps working as stated and my machine did not crash.
Thank you again for your help.
-Don