Tuesday, June 14, 2011

Private and Public Variables in Objective-C




    @interface MIMClass : NSObject
    {
        @private
        int _privateVar; //BY convention I usually put _ in front of private variables.
        


        @protected      
        int _myVar; //By default, every variable you define is in protected mode so if you don't          write protected above your variables, they are by default in protected mode.

        @public
        int publicVar;  // Can be accessed by any object,view
    }
    @end







I guess the code above pretty much explains how you can declare the private and public members in Objective-C

No comments:

Post a Comment