我有一个学生类:如何获得NSPopUpButton选定的对象?
@interface student : NSObject{
NSString *name;
NSDate *date;
}
和我有一个NSMutableArray的学生名单,并且我把它绑定到NSPopUpButton这样
内容:studentArray,arrangedObjects 含量值:studentArray ,arrangedObjects,名
我可以让学生对象是这样的:
-(IBAction)studentPopupItemSelected:(id)sender
{
NSPopUpButton *btn = (NSPopUpButton*)sender;
int index = [btn indexOfSelectedItem];
student *std = [studentArray objectAtIndex:index];
NSLog(@"%@ => %@", [std name], [std date]);
}
有没有什么办法可以直接从NSPopUpButton获取学生对象?像:
NSPopUpButton *btn = (NSPopUpButton*)sender;
student *std = (student *)[btn objectValueOfSelectedItem];
出于好奇,什么是触发'IBAction'列出? –