Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

doanelinde

macrumors member
Original poster
Jul 24, 2009
35
0
I have a basic understanding of pointers from C.

One thing that confused me for a while in objc with pointers was the fact that there was no dereferencing character being used, but I wasn't aware that that was what was confusing me, if that makes sense!

I think I've got a grip on that now.

But I'm still having a lot of issues with pointers and variables.

For instance I have a class with a list of properties, such as:
Code:
	NSInteger atmID;
	NSNumber *Latitude;
	NSNumber *Longitude;
	NSString *Add1; 
	NSString *Add2;
	NSString *Add3;

To me, this is a list of variables of different types. But there's some massive difference between the way the different types are working. And let's say I throw in a primitive C long there as well.

So Latitude is a pointer to a variable of type NSNumber? But NSInteger isn't a pointer, and when I @property it, I can't retain it, I simply assign it.
I've had no issues whatsoever working with the strings, but I have had issues working with integers and other variables.

These are really confusing me, and to be honest I just don't know what questions to ask. I've looked around and found a lot of information on pointers but still can't get my head around them.

Any help would be greatly appreciated, thanks in advance.
 
Also, the convention is to name your variables starting with a lower-case letter. Helps distinguish them from class names, which normally start with upper-case.
 
Yes, I looked at that before and from my understanding NSInteger is either a long or an int as from primitive c, depending on whether a 32 or 64bit variable is needed?

But I still don't understand the difference between these variables and pointers.

What's the difference between an NSString and an int as attributes of my object?


The reason I have these in upper case is because the names have to match the elements from an XML file I'm parsing in.


Thanks for the help!
 
What's the difference between an NSString and an int as attributes of my object?
NSString is a class and int is a C primitive. The former is an Objective-C construct and the latter is a C construct. If that confuses you, perhaps avoid the C primitives and use NSNumber instead of int.
 
maybe look at the relation of an array and a pointer, it may help you to understand them better
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.