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! While you're at it, check out some resources Treehouse students have shared here.
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
why is ball a pointer (*ball)? Is it not possible to just use a variable ball?
ball is declared as *ball. Does this mean it is a pointer? When are pointers used and when are normal variables used?
Andrew Boryk15,916 Points
Points are used to send the value of variable to an address in memory. The reason why you must have a point on Ball is because Ball is an Object, and all objects need to have a reference point in memory. Primitive data types don't require pointers, however you may use them. Objective-C is an object oriented language, so even Strings (which in other languages wouldn't be objects), are actually objects and are declared with NSString *string. Hope I helped, been programming in Objective-C for a little over two years. I could be off a bit, but that is what I've always told myself.
Michael Hulet47,911 Points
It's been a while since I've done iOS development (I haven't actually taken the Treehouse track, but I've done a very little in the past), but I think all objects in Objective-C are pointed to, and I think it has to do with the fact that they have setter and getter methods that you can modify, and those actually store the variable