iphone - 带有BOOL变量的init方法的 cocoa 风格指南?

标签 iphone objective-c ios

我有一个以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/

相关文章:

ios - cocoa pod 依赖管理

iphone - UIScrollView - 如何按需绘制内容?

objective-c - 主线程或后台线程解析swift

ios - WKInterfaceTable 不创建行

ios - 在 NSBundle 中加载自定义 NSBundle

android - 查看未找到不变违规

iphone - 如何绘制具有一定 alpha 透明度的 CGImage?

iphone - Scrollview 在dismissViewControllerAnimated 后没有滚动

objective-c - 在 Objective-C 中使用 NaCl/libsodium 加密

ios - 使用 Storyboard引用