0

If I declare instance variables and objects in my header between brackets with "IBOutlet" in front of them, do I have to set the objects properties?

Also does this mean they are private? What does it mean for them to BE private???

3 Answers 3

1

If you do @property and @synthesize you do not have to declare variables. The .h file is an api for a class so declaring anything inside it, has an intension to be public rather than private.

To declare IBOutlet private, you need to create a category,

@interface YourViewController ()

@property (nonatomic, retain) IBOutlet UILabel *label;

@end

Above code will be inside .m file.

Hope this will help

Sign up to request clarification or add additional context in comments.

Comments

0

No,It is not necessary to set properties for IBOutlets, Just declaring them would be enough for eg:

 IBOutlet UIbutton *btn;

If you want the variables to be private then you will have to declare it in this form

@interface myclass:NSObject
{
   @private
   int var1;
}

Instance variables declared as private in a class can be accessed only by an instance of the class.

Comments

0

You just have to declare variables of an object as IBOutlets (assuming you are hooking them up using Interface Builder). They don't have to be properties unless you have a reason to make them a property (i.e. you want the variable to be accessible by other objects). A private property can't be accessed by an external object.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.