How can I add custom attributes to interface controls?

Discussion in 'Mac Programming' started by printz, May 4, 2013.

  1. printz, May 4, 2013
    Last edited: May 4, 2013

    printz macrumors regular

    Dec 23, 2012
    I'm trying to give some extra data to some controls I'm putting in a dialog box. However, the "User Defined Runtime Attributes" entry from the Identity Inspector of Xcode XIB editor requires the class to have those properties defined. First, I tried creating categories for those controls, but Interface Builder (and the program in general) doesn't detect the new properties defined in the categories. Then, I subclassed the control classes (in this case, NSTextField and NSButton), the program started properly, but the controls looked all glitchy and broken and nothing worked.

    So, what's the best way to give custom attributes to controls? Is there a property I'm missing? I know there's the "identifier" property, but I don't want my custom attributes to be unique per control. Probably best for this purpose would be a dictionary, so I can use as many attributes as I wish.

    EDIT: is it okay if I click on the contained cells (NSCell-based) and set representedObject?

Share This Page