Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C private instance variables definition

Is there any difference in where we define private instance variables? As I understand there are two possibilties:

1) In header file

@interface MyViewController : UIViewController {
    @private
    NSString *fooString;
}

2) Second way is to define it in the implementation:

@implementation MyViewController
NSString *fooString;

What is the difference? Cheers!

like image 743
OgreSwamp Avatar asked Nov 27 '25 09:11

OgreSwamp


1 Answers

In 2nd case fooString is not instance variable - it is global variable, so your two cases are completely different

like image 183
Vladimir Avatar answered Nov 30 '25 00:11

Vladimir



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!