View Full Version : A quick beginner question
Meriana
Nov 30, 2009, 06:31 PM
Hi everyone
I'm sure if read it, but i can't find it in the book about Objective-C 2.0 i'm using anymore:
What means the * infront of a the name of a new instance of an class:
NSObjects *newObject
or in cases like this:
-(void)setName:(NSString *)newName
thanks in advance.
chown33
Nov 30, 2009, 06:50 PM
In that context, it means "pointer".
lee1210
Nov 30, 2009, 07:05 PM
In Objective-C every object is stored on the heap, with pointers on the stack used to access them (via message passing). Because of this, every object instance you're dealing with will be via pointer. You can also have pointers to primitive types, just as in C, but these are going to be treated differently. They will be manipulated using * to dereference, etc instead of having messages passed. You can probably get by without it, but this is a major reason I think a foundation in C helps when learning Objective-C.
-Lee
Meriana
Nov 30, 2009, 07:51 PM
Well thanks. :)
Though either i have a really good book or Objective-C 2.0 is really easy to learn.
Do you think i should get myself a book with a quick introduction to C?
lee1210
Nov 30, 2009, 08:26 PM
I do. Other people disagree. I think a foundation in C is helpful, but it's probably not strictly necessary. I feel like knowing C is a net positive, I don't think anything you learn will be useless in other languages.
-Lee
GorillaPaws
Dec 1, 2009, 06:43 PM
You might want to have a look at this tutorial (http://www.masters-of-the-void.com/). It has a really great section on how memory works, that should prove helpful. I don't think you need to be a C guru to work through introductory Cocoa books, but a solid understanding of the fundamental concepts (such as memory management, pointers, variable scope etc.) is pretty essential.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.