Moon
Moon

Reputation: 22575

Is this considered a property?

I just jumped into Objective C.

When I create a button and connect it to my code, I get the following line of code in my property section:

IBOutlet UIButton *btn;

I've learned that a property syntax is [class] *[variable name].

What is IBOutlet in this case?

Upvotes: 1

Views: 62

Answers (3)

edc1591
edc1591

Reputation: 10182

That is not a property. That is just a variable declaration. The property version of that would be

@property (nonatomic, retain) IBOutlet UIButton *btn;

And then in your implementation file, you would place

@synthesize btn

just below the @implmentation line.

Upvotes: 2

Michael Pasqualone
Michael Pasqualone

Reputation: 2037

No. IBOutlet is simply a macro that resolves to nothing.

Their purpose is to simply let Interface Builder know that your variables (in your case UIButton *btn) can be used to link UI elements to your code within Xcode.

Upvotes: 2

aleph_null
aleph_null

Reputation: 5786

Have you ever used interface builder? IBOutlet is a macro that lets you refer to views in interface builder from your code. In your case, it lets you hook up the UIButton to interface builder so that you can use a reference to it from within your code. Other than being used to let interface builder you want to hook up the variable to a view, it's not used at all and actually resolves to nothing.

Upvotes: -2

Related Questions