Title: asterisk in variable declaration in headers in obj-c
Tags: objective-c;pointers;variables
Question: I get that asterix is for pointers, and I understand about pointers now. But I'm still not sure why when declaring a variable in a header I need to use an asterix, for example:
UINavigationController * navController;
why isn't that:
UINavigationController navController;
Thanks

Here is the accepted answer: Because in your example:
UINavigationController * navController;
navController is a pointer to object of UINavigationController type;
and you always work with pointers using Objective-C objects, when you create new instance with:
[[MyClass alloc] init]
it returns pointer to newly created object of type MyClass i.e (MyClass *)

Here is another answer: In the header you are declaring the memory that needs to be allocated for an object.  You need to use the * operator because you only want to declare memory space for a reference/pointer to the object, and not space for the object itself.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 2.5', 'CreationDate': '2010:00:03/10/10', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<objective-c><pointers><variables>', 'Title': 'asterisk in variable declaration in headers in obj-c', 'ViewCount': 399, 'id': 2416429, 'user_AboutMe': "<p>I'm a 25 year old Software engineer in London, proudly working on the Elfin Market iOS app.</p>\n<p>I've made a few tweaks for jailbroken iOS and some other stuff.</p>\n", 'user_AccountId': 64959.0, 'user_DisplayName': 'Jonathan.', 'user_Reputation': 52397.0, 'user_Views': 2747.0, 'user_id': 191463.0}}