Search code examples
objective-cxcode4nsstringiboutlet

xcode NSString IBOutlet to NSString Object in designer?


I have a UIView extended class which has an extra NSString property. For convenience I'd like to somehow set that property in the designer, if possible.

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

The property will show up as an Outlet as expected. I connect it to an NSString Object that was added from the Objects Library (added as Plain Object, class changed to NSString). But I'm unable to edit the string through the designer Attributes Inspector... is there a way?

I know it's possible to use a UILabel, but that's overkill and I don't need the convenience that badly.

Thanks.


Solution

  • I fear there's no way you can modify your NSString from IB.

    If you need the string to have an initial value consider reimplementing method

    -(id)initWithCoder:(NSCoder*)coder
    

    of your controller and manually set your NSString. For example

    -(id)initWithCoder:(NSCoder*)coder {
    
        self = [super initWithCoder:coder];
        if (self) {
            designerAccessibleString = @"somestring";
        }
    
        return self;
     }