I’m fairly new to c2dx and I’m looking for anyway I can to import the loading system I wrote for Cocos2d.
Are there any c2dx analogs for NSSelectorFromString, NSClassFromString, and respondsToSelector?
I’m basically trying to convert this code:
- (id) itemWithDict:(NSDictionary*)itemDict withDelegate:(id)del {
Class type = NSClassFromString([itemDict objectForKey:@"type"]);
id newItem;
if ([type respondsToSelector:@selector(itemFromNormalSprite:selectedSprite:target:selector:)]) {
SEL itemSel = NSSelectorFromString((NSString*)[itemDict objectForKey:@"selector"]);
newItem = [type itemFromNormalSprite:[CCSprite spriteWithSpriteFrameName:[itemDict objectForKey:@"img"]
selectedSprite:[CCSprite spriteWithSpriteFrameName:[itemDict objectForKey:@"imgSel"]
target:del
selector:itemSel];
}
return newItem;
}
And as I’m sure you can imagine I’m running into some trouble.
I’m not looking for a detailed solution but can anyone point me in the right direction with regards to those particular methods? Thanks!