我正在尝试给 NSMutableArray 值“SEL”,而 XCode 给我这个错误。我的代码:
SEL camera=@selector(p_userAlbum);
NSMutableArray *sels=@[camera].mutableCopy;
是否有办法将 SEL 放入数组?
最佳答案
使用 NSStringFromSelector
和 NSSelectorFromString
很容易实现
//Save
SEL camera=@selector(p_userAlbum);
NSString * selName = NSStringFromSelector(camera);
NSMutableArray *sels=@[selName].mutableCopy;
//Get
NSString * name = sels[0];
SEL mySel = NSSelectorFromString(name);
关于ios - ‘SEL' 类型的集合元素不是 Objective-C 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33991067/