XCode Cocoa 学习日志之二;

-----------利用  Categories  实现私有方法.

#import <Cocoa/Cocoa.h>

 

 

@interface MyClass: NSObject

-(void) publicMethod;

@end

 

----------------MyClass.m----

 

#import "MyClass.h"

 

// private methods

@interface MyClass (Private)

 -(void) privateMethod;

@end

 

@implementation MyClass (Private)

-(void) privateMethod {

    printf( "private method/n" );

}

@end

 

 

 

@implementation MyClass

-(void) publicMethod {

    printf( "public method/n" );

[self privateMethod];

 

}

@end

-------------------这个方法有些别扭,不喜欢-------

posted on 2010-06-11 14:31  老代哥哥  阅读(120)  评论(0编辑  收藏  举报

导航