Reputation: 748
I am a little bit confuse about the this:
Why do some programmers use this at their .h file
{
IBOutlet UIScrollView* scrollView;
IBOutlet UIPageControl* pageControl;
}
@property (nonatomic, retain) UIView *scrollView;
@property (nonatomic, retain) UIPageControl* pageControl;
Instead just this...
@property (nonatomic, retain) UIView *scrollView;
@property (nonatomic, retain) UIPageControl* pageControl;
I am new to XCode and Objective C , I will be glad if there is anyone who can explain me this. Thanks.
Upvotes: 1
Views: 111
Reputation: 25144
Outlets are properties
properties need an ivar (unless some very specific case)
Since Xcode 4.3 or 4.4, ivars are automatically added and synthesized by the compiler if absent.
Upvotes: 0
Reputation: 20410
In recents versions of the toolchain, it's enough just doing this:
@property (nonatomic, retain) IBOutlet UIView *scrollView;
(If you dont put the IBOutlet you wont be able to connect it to the interface builder)
Some people still do it in the old way, some of them just tradition, some dont know it can be skipped, or it's because they are just old projects.
Upvotes: 2
Reputation: 410722
It was only relatively recently that you could declare properties without a corresponding instance variable (the compiler will create the backing instance variable for you now if necessary, but that wasn't always the case).
Upvotes: 1