Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Objective-C Basics (Retired) Introduction to Objective-C From Structs to Objects

Matthew Chess
Matthew Chess
13,860 Points

Declare a pointer vs an int?

In this video they write...

NSArray *_center;
float _radius

Why do you user a pointer to center for NSArray but float for the variable radius?

2 Answers

In Objective-C the only way you can get to an Object is through a pointer. So:

NSArray *myArrayOne = [NSArray arrayWithObjects: @"One",@"Two",@"Three",nil];
NSArray *myArrayTwo = myArrayOne;
myArrayOne = nil;
Matthew Chess
Matthew Chess
13,860 Points

So for primitive data types I can just pass a value into the variable but for objects they need a pointer?

It would be illegal to write...?

NSNumber one = @1;