Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C use of pointers

When do you and when dont you need the * symbol (which is because in objective-c all variables like NSString are pointer variables)?

For example when do you need to do "NSString *" instead of just "NSString"?

like image 998
Devoted Avatar asked Jun 30 '09 23:06

Devoted


1 Answers

In Objective-C, all object references are pointers, so you always need the pointer operator when you declare with an Objective-C object.

For other types, the use is exactly the same as in C. Use pointers when you want to pass data structures or primitive types by reference.

like image 105
Jason Coco Avatar answered Oct 15 '22 09:10

Jason Coco