In Objective-C, I’ve seen, for example:
UIPickerView *tweetPicker
and
UIPickerView* tweetPicker
What does the asterisk mean (I know, the first part is a dupe…) and why does it go on different parts of the declaration in different contexts?
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.
In the exact case you’re showing, there is no difference. Some people like to think of
tweetPickerbeing of typeUIPickerView *, that is, a pointer to aUIPickerView. These people usually write it asOther people prefer to think of it like
*tweetPickeris aUIPickerView, that is, dereferencing the pointer gives aUIPickerView. Those people usually write:I prefer the latter, because the C (and Objective-C because of that) syntax supports it better. Take, for example, the following variable declarations:
At first glance, the novice C (or Objective-C) programmer might say “those are the same”, but they’re not. In the first case,
bandcare regular integers, in the second case, they’re pointers.ais a pointer in both cases.From my perspective, the concept of a “type” is so weak in C anyway (what with the behaviour of typecasting and the like) that extending that concept one step further to pointer variables is crazy – especially with the automatic & silent conversions to and from
void *oridthat you get.