All of the examples of categories that I've seen use some Objective-C class rather than a custom class. For example: NSMutableArray, NSArray, NSString. I'd like to create a category for a custom class. Here's a useless example I created just to test but fails compilation:
//person.h
@interface Person (aCategory) : NSObject {
NSString *MyName;
NSString *webAddress;
}
@property(nonatomic, retain) NSString *MyName;
@end
//person.m
#import "Person+aCategory.h"
@implementation Person
@synthesize MyName;
@end
And the category definition:
@interface aCategory : NSObject {
NSString *webAddress;
}
@property(nonatomic, retain) NSString *webAddress;
- (void)changeWebAddress;
@end
//in aCategory.h
#import "aCategory.h"
@implementation aCategory
@synthesize webAddress;
- (void) changeWebAddress{
self.webAddress = @"http://www.abc.com";
}
@end
This will give the following errors and warning:
error: Person+aCategory.h: no such file or directory
warning: cannot find interface declaration for Person
error: no declaration of property 'MyName' found in interface
Is there a way to do this?