I’m trying to subclass UIColor, and I can’t seem to figure out what’s wrong.
In my PColor.h
#import <Foundation/Foundation.h>
@interface PColor : UIColor {
BOOL isAvailable;
int colorId;
}
@property (nonatomic, assign) BOOL isAvailable;
@property (nonatomic, assign) int colorId;
@end
…and in my PColor.m
#import "PColor.h"
@implementation PColor
@synthesize isAvailable;
@synthesize colorId;
@end
Upon instantiating a PColor object, I get:
//warning: incompatible Objective-C types initializing 'struct UIColor *', expected 'struct PColor *'
PColor *pcolor = [[PColor alloc] initWithHue:1 saturation:0 brightness:0 alpha:1];
Am I missing something? Thanks in advance.
UIColoris a class cluster use associative references in a category to add properties! All of the custom init methods onUIColorreturn aUIColor*not anidso you can not easily subclassUIColornor should you try.UIColor+PCOLOR.h
UIColor+PCOLOR.h
USAGE