2010-10-29 49 views

回答

6

@private是爲ivars而不是爲方法。只需在.m文件的頂部創建一個類擴展,並將私有方法放在那裏。它看起來像

@interface MyClass() // note the empty parens 
- (void)onePrivateMethod; 
- (void)twoPrivateMethod; 
@end 

@implementation MyClass 
// implement everything 
@end 
+1

完全正確的保存添加「在Objective-C中沒有真正的私有方法」。更多細節在這裏:http://stackoverflow.com/questions/2158660/why-doesnt-objective-c-support-private-methods – bbum 2010-10-29 05:04:54