objective-cclasssyntaxivar

Objective-c syntax - Class *var vs Class* var


I'm from a PHP background and I'm new to Objective C. I get that an asterisk before a var identifies it as a pointer. However what does an asterisk AFTER a CLASS NAME mean? I've seen it both ways and it's not a mistake. Is a style difference with the same meaning?

Class *var  
Class* var 

Solution

  • Same meaning. Using the asterisk after the class name is somewhat misleading in case of multiple variable declarations; for example, in this line:

    Myclass* a, b;
    

    the asterisk only applies to a. But some people argue that * is a part of the datatype, therefore belongs together with the class name.