Chi*_*ron -1 cocoa-touch objective-c private-methods
当我想在Objective-C中创建私有方法时,我应该使用什么?
1)众所周知的类别技术.
2)@private指令.
(我正在进行iOS开发).
@private适用于ivars,不适用于方法.只需在.m文件的顶部创建一个类扩展,并将私有方法放在那里.它看起来像
@interface MyClass () // note the empty parens
- (void)onePrivateMethod;
- (void)twoPrivateMethod;
@end
@implementation MyClass
// implement everything
@end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
491 次 |
| 最近记录: |