as the title says, what is the difference between a pointer and an object.
Say I have this code..
NSString *red = [[NSString alloc]initWithFormat:@"%@"];
and this code..
NSString *blue = [NSString stringWithFormat:@"%@"];
Is it correct to assume that they’re both pointers to an object and pretty much the same? And if so, how should I think of objects in my mind ?
I do apologize if the answer exists already, I did use the search function but I’ve only found examples of this in the C++ language and wanted to make sure how it was in objective-c.
In addition to Basile Starynkevitch and Bram’s answer,
In objective C the difference between your code line is,
**Above code says you own red object so it’s your responsibility to release it.
**You don’t own it someone else in your program deep down inside will own this and you don’t have to release this.
I would suggest for more information reading Apple’s documentation is GREAT! specially Learning, “Objective C programming guide”
Good luck!
PS : iOS 5 has new feature, memory management is done by iOS itself, Now developer can be more creative instead doing 3 grade mathematics of reference counting 🙂