I’m starting out Objective-C and I was wondering, why do we have to put asterisks in the method parameter type?
e.g.
- (void)myMethodThatTakesAString:(NSString*)string;
Thanks in advance!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The asterisk means that the parameter is a pointer to an NSString. You can’t pass an NSString to a method, but rather you pass a pointer to it.
Although you might get away with simply using pointers when you have objects and not really understanding them, it’s probably a good idea to prioritize learning about pointers.