Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

resetme

macrumors newbie
Original poster
Oct 28, 2012
23
0
Noob question, what is the difference declaring variables like this (.h file)?

case 1:
Code:
@interface my App : UIViewController{
    IBOutlet UIImageView *imageView;
}

@property (weak, nonatomic) IBOutlet UIImageView *imageView;

case 2:
Code:
@interface my App : UIViewController{
    IBOutlet UIImageView *imageView;
}

case 3:
Code:
@interface my App : UIViewController
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

for me they all do the same.. instance variables.
 
Case 1: You have an instance variable called imageView and also have getter and setter methods for that variable.

Case 2: You have only an instance variable but no getters or setters

Case 3: you have getters and setters but no instance variable. If you do this you will need to create the instance variable when you synthesize the property, e.g @synthesize imageView = _imageView;

Also, IBOutlets should be strong, not weak, if I'm not mistaken
 
Case 3: you have getters and setters but no instance variable. If you do this you will need to create the instance variable when you synthesize the property, e.g @synthesize imageView = _imageView

@synthesize isn't necessary anymore; unless I'm mistaken, an instance variable named _propertyName will be assumed.
 
Ty guys... always helpful!

I think that weak is for default and strong for controller.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.