3 Replies Latest reply: Feb 5, 2013 10:02 AM by Febwind
Febwind Level 1 Level 1 (0 points)

Does objective-c has the same access level as Java? For example, private, public,default and protected?

  • 1. Re: objective-c access level?
    etresoft Level 7 Level 7 (24,270 points)

    Yes, but they are rarely used. You can specify @protected or @private if you want. That is an artifact of old-school object-oriented software which really isn't practical in the real world.

  • 2. Re: objective-c access level?
    g_wolfman Level 4 Level 4 (1,120 points)

    You can indicate that attriburtes are public, protected or private, which will protect them from illegal access at compile-time.  Protected is the default in Objective-C.  However, becasue Objective-C is a dynamic language, you can't really control run-time access to the attributes the way you can in a static language.


    All methods are public, all the time, in Objective-C.  You can mark them as @interface and @implementation to indicate that they are (or aren't) supposed to part of the object's API.  Methods marked @implementation won't be exposed.  But that doesn't actually stop anyone from calling them if they know the methods exist.

  • 3. Re: objective-c access level?
    Febwind Level 1 Level 1 (0 points)

    Thanks to give me more detail. That is really helpful to clear my confusions