开发者

NSArrayController bindings without Core Data

I have an NSArrayController, the content of which I would like to be a list of the CGDirectDisplayIDs of all of the connected Screens. Right now I have the following code:

NSArray* screens = [NSScreen screens];
for (NSScreen* screen in screens)
{
    NSNumber* screenId = (NSNumber*)[[screen deviceDescription] valueForKey:@"NSScreenNumber"];
    [d开发者_开发问答isplaysList addObject:screenId];
}

[displaysArrayController setContent:displaysList];

displaysList is an NSMutable array which is allocated in awakeFromNib, what do I need to do in interface builder to populate a popup button with the values in displaysList?


  1. In the class with the code you posted above add a new NSArray property. Call it for
    instance displaysArray
  2. Add a NSArrayController which you connect to the IBOutlet displaysArrayController
  3. In the Interface Builder you'll find a group called "Object Controller" Set its mode to "NSArray" Disable the check "Prepares Content"
  4. In another section you'll find a group called "Controller Content". Enable the checkbox and bind it to the object with the property displaysArray. Set the model key path to displaysArray.

I hope that helps :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜