我有一个以bool值开头的数据类:
- (id)initWithBool:(BOOL)hasSomeValue anotherVariable:(var type)var ...
但这在XCode中实例化时不可读,因为在显示自动完成时不会显示“hasSomeValue”。
-(id)initWithHasSomeValue:(BOOL)hasSomeValue anotherVariable:(var type)var ...
也比较笨拙。我已经进行了一些搜索,但是似乎找不到苹果推荐的规格。
编辑:指向Apple的示例的指针将非常有帮助。我仍然没有找到一个。
最佳答案
您真的想要一些可以告诉您BOOL实际代表什么的东西
- (id)initWithBool:(BOOL)hasSomeValue ...
- (id)initWithHasSomeValue:(BOOL)hasSomeValue ...
相当于
- (id)initWithString:(NSString*)string ...
如果您正在启动BOOL(显然是废话),但使用
[NSNumber numberWithBool:]
除外
关于iphone - 带有BOOL变量的init方法的 cocoa 风格指南?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8063982/