small medium large xlarge

30 Jul 2009, 16:28
Linda Miller (4 posts)

I am having a hard time understanding a couple of things in ObjC.

First is the proper use of the asterisk. I get it about when you are creating an instance such as: Movie *movie =[[Movie alloc] init];

Where I don’t get it is when you put an asterisk before a close parenthesis vs just a closed parenthesis.

  • (NSString *) title;


-(int) myNumber

The other thing that I am having difficulty with is when parenthesis are used around an ObjC string

[movie setTitle:@”iron man”];

and something similar:

NSLog(@”our movie is %@, movie);


01 Aug 2009, 12:23
Bill Dudney (917 posts)

Hi Linda,

The ‘’ character means ‘this variable is a pointer’. So NSString *foo says that I’ve got a pointer to an NSString. The int return type above says that the myNumber method returns an int and likewise the (NSString *) says that title returns a pointer to an NSString. All objects in Objective-C are pointers (thus you always see the ‘’).

The Kochan book is a good starting point for getting your head wrapped around Objective-C. You can also get a copy of ‘A Book on C’ to help you understand more of what is going on with the language.

Good luck!

  You must be logged in to comment