Xcode NSString IBOutlet for NSString object in designer?

I have an extended UIView class that has an additional NSString property. For convenience, I would like to somehow set this property in the constructor, if possible.

@property (nonatomic,retain) IBOutlet NSString* designerAccessibleString;

      

The property will appear as output as expected. I am connecting it to an NSString object that was added from the Object Library (added as a regular object, class changed to NSString). But I can't edit the line through the Attributes Inspector ... is there a way?

I know it is possible to use UILabel, but this is overkill and I don't need bad usability.

Thank.

+3


source to share


2 answers


I'm afraid you won't be able to change yours NSString

from IB.

If you need a string for the original value, consider the override method

-(id)initWithCoder:(NSCoder*)coder

      



your controller and manually install NSString

. for example

-(id)initWithCoder:(NSCoder*)coder {

    self = [super initWithCoder:coder];
    if (self) {
        designerAccessibleString = @"somestring";
    }

    return self;
 }

      

0


source


This can be done using the User Defined Runtime Attributes in the Identity inspector:

User Defined Runtime Attributes in XCode 5



In this example, the initialRelativeUrl property is set when the view controller is loaded.

+1


source







All Articles