smcguffee Posted August 12, 2012 Share Posted August 12, 2012 Hi, I'm starting to get more comfortable using Objective C++ coming from a C/C++ background. I'm just realizing one of the things that has been confusing me, so I'm wondering if anyone can help me figure it out. Basically what I realized is that pointers in Objective C++ or Objective C can have . operators (?) to access members, but in C and C++, pointers need -> to access members. I notice that when I access my C and C++ members of objective C++ classes (?), I have to use . to access Objective C++ members (properties?), while simultaneously using -> to access C and C++ members. What is going on with this? What is the meaning of using a . on a pointer in Objective C++? Do I simply have to make pointers of objective C++ class pointers to get objects the way I think of them in C++? Thanks in advance, Sean Link to comment https://www.insanelymac.com/forum/topic/281765-objective-cc-pointers-using/ Share on other sites More sharing options...
TH3L4UGH1NGM4N Posted August 19, 2012 Share Posted August 19, 2012 In objective C, pointers uses the asterisk * to denote a pointer. The period is used when you have properties of an object for instance: @interface MyClass : NSObject NSObject *Cars; // an object car int weight,speed; // just two integer values // declare the properties of the Class @property(nonatomic) int weight; @property(nonatomic) int speed; Then in your implementation file aka the .m file @implementation MyClass @synthesize weight,speed; // must synthesize properties you create // now you may use the properties -(void)someFunction { Car.weight = 1593; Car.speed = 155; } Link to comment https://www.insanelymac.com/forum/topic/281765-objective-cc-pointers-using/#findComment-1845391 Share on other sites More sharing options...
Recommended Posts