Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个NSMutableArray实例,名为myArray. 它包含 8 个按钮对象。如何获取已粘贴到整数变量的按钮的索引?
NSMutableArray
myArray
NSArray有一个方法叫做indexOfObject
NSArray
indexOfObject
- (IBAction)pushButton:(id)sender { NSButton *button = (NSButton *)sender; NSUInteger index = [Array indexOfObject:button]; }