I tried my hand on a Stanford iPhone course on iTunes U and I got a little confused about the pointers. In the first assignment, I tried to do something like this
NSString *processName = [[NSProcessInfo processInfo] processName]; NSInteger *processID = [[NSProcessInfo processInfo] processIdentifier];
Having generated an error, after the blind blind, I found that it was in the NSInteger line that the problem arose.
Therefore, I obviously do not understand what is happening. I will explain how I think this works, and maybe someone will be kind enough to point out a flaw.
Unlike web development, I now need to worry about memory, well, moreover than in web development. Therefore, when I create a variable, it gets the allocation of bits of memory (RAM I assume). Instead of putting a variable around, I pass a pointer to this bit of memory around. And also pointers are declared by prefixing the variable name with *.
Assuming I'm right, which puzzles me, why don't I need to do this for NSInteger?
pointers integer objective-c cocoa nsinteger
gargantuan Jun 18 '09 at 17:29 2009-06-18 17:29
source share