开发者

NSArrayController for polymorphic class

I have the following (stripped down) class interfaces:

@interface ScriptEvent : NSObject {
  ...
}

@interface SingleLine : ScriptE开发者_C百科vent {
  NSString *line;
}

@interface MultiLine : ScriptEvent {
  NSArray *lines;
}

Another parent class holds an NSArray containing a list of ScriptEvents (which will either be SingleLine or MultiLine).

In my XIB I have an NSArrayController bound to this list of ScriptEvents and I want to set up a master/detail arrangement. So I have an NSTableView linking to this NSArrayController and I want to show a different detail panel depending on whether the selected member of the NSArrayController is a SingleLine or a MultiLine.

Is this possible?


Check if the selected member is a SingleLine or a MultiLine with:

if([objectToCheck isKindOfClass:[SingleLine class]]){
    //Do some staff
}else if([objectToCheck isKindOfClass:[MultiLine class]]){
    //
}else{
    //
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜