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 Simple iPhone App (iOS7) Refactoring into a Model Understanding @property

Invisible?

When it is said that methods are "invisible to us." What does that mean?

6 Answers

Hi, Aaron Eckhart:

In terms of properties, in addition to encapsulation, Objective-C--like most object-oriented programming languages-- provides you and other programmers various ways of restricting or contextualizing how and when certain variables and methods can be accessed, added on to, or changed.

The term 'invisible to us' means the methods or variables regarding a particular program isn't directly accessible to us. This is necessary for certain classes, methods, and values act in reliable ways.

Just like how you don't expect to be able to go into a kitchen as you please at a restaurant when you order something from a restaurant, it's sort of the same thing when it comes to interacting with most things in Objective-C you didn't code.

You can't access certain methods and values of an Objective-C as you please despite the fact you want certain things from a particular class. The programmer(s) of the class designed it to be interacted a certain way.

Hopefully (and thankfully in most cases), the class, method, or value came with documentation that made it clear how to get relevant output from it.

This allows you to get what you want, and the class, method, or variable worry about the little details you probably don't care about towards giving you want you want.

Does this make sense?

Makes total sense, good explanation, thanks a lot

No problem; glad I could help. Please mark it as a best answer so it's clear to others you've been helped; you'll find out the community's pretty active to answer fun questions such as this one. :)

Well since I got you here... is it true that its still possible to access methods even if we can't see them?

Yes and no; During runtime It's not entirely impossible, but a well designed program would make variables, methods, and classes not intended to be accessed cause a crash if forcibly accessed.

Your interaction with such private or protected methods, variables, and classes would be abstracted from you through interactions, events, and specific methods that act as getters and setters to such private things without you directly interacting with them, as well as perhaps as a result of an object inheriting a certain class's characteristics as a base towards having characteristics of its own.

The extent you can do such things, including ways of accessing private & protected variables forcibly without error, involves a variety of techniques associated with metaprogramming.

excellent man, thanks again