0

Possible Duplicate:
IBOutlet and IBAction

I am a newbie to iphone development and have some basic question to ask .I am interested in knowing the difference between three codes. First Code:

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController <UIScrollViewDelegate> {
    UIScrollView *scrollView;
}

@property (nonatomic, retain) IBOutlet UIScrollView *scrollView;

Second Code:

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController <UIScrollViewDelegate> {
    IBOutlet UIScrollView *scrollView;
}

@property (nonatomic, retain) IBOutlet UIScrollView *scrollView;

Third code:

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController <UIScrollViewDelegate> {
    IBOutlet UIScrollView *scrollView;
}

@property (nonatomic, retain) UIScrollView *scrollView;

Need some clarification on this.

Community
  • 1
  • 1
lakshmen
  • 28,346
  • 66
  • 178
  • 276

4 Answers4

3

IBOutlet keyword is for connecting stuff in Interface Builder to code. See https://developer.apple.com/library/mac/documentation/General/Devpedia-CocoaApp-MOSX/Outlet.html

Kreiri
  • 7,840
  • 5
  • 30
  • 36
1

IBOutlet is ignored by the compiler, so these 3 codes are equivalent for the compiler.

Felix
  • 35,354
  • 13
  • 96
  • 143
1

IBOutlet is #define'ed to an empty token (nothing), so it doesn't really matter if or not it's used. Except that Interface Builder uses this to discover which objects are to be connected and used in a XIB file. (As a beginner, I strongly encourage you to learn how to make UI programmatically and only use Interface Builder when you can make a UI using code.)

1

All are same...

If we want to connect the object creating in .h file with the object dragged in interface builder then we have to use IBOutlet..

We can use IBOutlet while declaring object or while creating property for that.If,we write IBOutlet two times also there is no problem

Sandeep
  • 221
  • 1
  • 9