3

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.

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
Ivan Dossev
  • 565
  • 5
  • 11

2 Answers2

1

You can do this using the User Defined Runtime Attributes section of the identity inspector:

User Defined Runtime Attributes in XCode 5

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

Ian Newson
  • 7,679
  • 2
  • 47
  • 80
0

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;
 }
Manlio
  • 10,768
  • 9
  • 50
  • 79
  • I'm doing essentially the same thing now, but through a different init method. At least I don't have to wonder now. Too bad Apple did not implement basic Objects like NSString, NSNumber, etc. to have a property in the Attributes Inspector. – Ivan Dossev Mar 30 '12 at 20:56
  • This isn't true, you can use the user defined attributes section of interface builder to set arbitrary properties. – Ian Newson Jan 13 '14 at 11:47