以下是在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