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

Vishwas Gagrani

macrumors newbie
Original poster
Sep 26, 2012
22
0
Code:
-(NSString*)myField{
return myField; 
}

What's what here ?

NSString seems to be type of myField.

But where is the function name ? What's the myField doing after (NSString*). What's the * after NSString. Is * similar to "Pass by Value", "Pass by Reference" as in C,C++?


thanks
V.
 
Last edited by a moderator:
This can all be answered if you know the fundamentals of Objective-C. What resources are you using to educate yourself on the basics?
 
It's a method (not a function.) Its return type is a pointer to an NSString. The method name is myField, and it returns the instance variable, also named myField. This method is a getter for the instance variable myField.

Having a getter like this isn't very common anymore with properties, which can automagically create getters and setters for you, having been introduced in Obj-C 2.0.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.