

class myClass.h
@interface test : UIViewController{
}
-(NSString *) method 1;
-(NSString *) method 2;
@end
class myClass.m
@implementation{
-(NSString*) method1{
return( @"method1");
}
-(NSString *)method2{
return (@"method2");
}
}
/////
class yourClass.h
#import "myClass.h"
@interface{
...
}
class yourClass.m
@implementation{
-(void)viewdidLoad{
myClass * _myclass = [[ myClass alloc]init];
NSLog(@"%@),[_myclass method1]);
NSLog(@"%@),[_myclass method1]);
}
}
//////// Category implementation. (className +categoryName)
Step 1
Choose the Category template from the XCode new file.

Step 2
Category on the name for the super-class.

#import <Foundation/Foundation.h>
#import "myClass.h"
@interface myClass(ktest)
-(NSString *) method4;
-(NSString *) method5;
@end
#import <Foundation/Foundation.h>
#import "myClass.h"
@interface myClass(ktest)
-(NSString *) method4;
-(NSString *) method5;
@end
//// Category class.m file
#import "myClass+ktest.h"
@implementation myClass(ktest){
-(NSString *) method4{
return (@"method4");
}
-(NSString *) method5{
return (@"method5");
}
/// Category Implementation in your Derived Class
yourClass.m
#import"myClass.h"
#import "myClass+ktest.h"
@implementation{
-(void)viewdidLoad{
myClass * _myclass = [[ myClass alloc]init];
/**After Importing the "myClass+ktest.h" same object of _myClass can implement all the method i.e myClass and methods from myClass+test **/
NSLog(@"%@),[_myclass method1]);
NSLog(@"%@),[_myclass method2]);
NSLog(@"%@),[_myclass method3]);
NSLog(@"%@),[_myclass method4]);
}
}

Sachin BhardwajPosted Feb 8, 2013, 11:08 AM
Very nice article thanks kush sir....