gdiazc
gdiazc

Reputation: 2148

How to set attributes for a custom UI element?

I am trying to program a very simple calculator for iOS. I have a storyboard in XCode with several buttons, which are actually my own subclass:

@interface CalcButton : UIButton
{
  int digit;
}
@property int digit;
@end

In the "Identity Inspector" I was able to select a "Custom Class" for by buttons. How would I now set the digit attribute for my buttons?

Upvotes: 0

Views: 270

Answers (1)

Greg
Greg

Reputation: 25459

You won't be able to set this property in storyboard.

You can do it in code by creating outlet from your custom class (CalcButton) in storyboard to the class (mostly UIViewController or UIView) which own this controls and in your code you can do it for example in viewDidLoad method:

self.yourCalcButtonOutlet.digit = 2;

Upvotes: 1

Related Questions