I try to extend the functionality of SimpleAudioEngine of cocos2d with the ability to play several sound effect one after another as some kind of chain. I tried to do this w
You can not add iVars but can add property variables. Something like below:
In your .h:
#import
@interface Chair (Liking)
@property (nonatomic, assign)BOOL liked;
@end
In your .m:
#import "Chair+ChairCat.h"
@implementation Chair (Liking)
-(BOOL)liked{
return [ objc_getAssociatedObject( self, "_aliked" ) boolValue ] ;
}
-(void)setLiked:(BOOL)b{
objc_setAssociatedObject(self, "_aliked", [ NSNumber numberWithBool:b ],OBJC_ASSOCIATION_RETAIN_NONATOMIC ) ;
}
@end
Then somewhere in some other class say myViewController.m
#import "Chair+ChairCat.h"
- (void)viewDidLoad {
/////
Chair *chair = [[Chair alloc] init];
[chair setLiked:NO];
}