以下是在Objective-C私有方法的一個示例:Objective-C的呼叫私有方法
#import "MyClass.h"
@interface MyClass (Private)
-(void) privateMethod:(NSString *)arg1 and: (NSString*)arg2;
@end
@implementation MyClass
-(void) publicMethod {
NSLog(@"public method\n");
/*call privateMethod with arg1, and arg2 ??? */
}
-(void) privateMethod:(NSString *)arg1 and: (NSString*)arg2{
NSLog(@"Arg1 %@ and Arg2 %@", arg1, arg2);
}
@end
我讀過有關專用接口/方法聲明
MyClass.m。但如何從其他公共方法調用它們? 我試過[self privateMethod:@"Foo" and: @"Bar"]
,但它看起來不正確。
看起來我的權利。 – badgerr 2011-01-25 13:26:56