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

iOS Build a Blog Reader iPhone App Viewing a Web Page Opening a Web Page in Safari

What does a single instance of UIApplication represent in this video?

As explained in the documentation of UIApplication class, "Every app must have exactly one instance of UIApplication (or a subclass of UIApplication)".

Does it mean that I can't declare a UIApplication object anywhere else in the app after declaring it once in my table view controller class? If so, what is the reason?

1 Answer

When you declare '''UIAppliation *testApp = [UIApplication sharedApplication]''' you are not declaring a UIApplication, but you are declaring a pointer. It is the exact same thing if you just typed '''id''' but that's not good practice when it isn't needed.

The pointer just hold the address of the where your UIApplication instance is saved.

Rememeber: if you have an Asterix in the declaration it is a pointer to the memory address, not the actual instance. >> So I declare two pointers that point to the same address and if I change the properties of an object using one of those pointers, it will be reflected in the dereferencing of the other one as well.

Thanks for your reply Madhav. I was wondering if you could help me differentiate between an object and an instance by giving an ObjectiveC code example as it would turn out to be really helpful. Thanks in advance :)