Forums » C++ Framework » c2dx analogs for NSSelectorFromString, NSClassFromString, and respondsToSelector? »
| A Slushie | c2dx analogs for NSSelectorFromString, NSClassFromString, and respondsToSelector? | ||
|---|---|---|---|
|
Added by A Slushie over 1 year ago
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! |
||
| RongHong Huang | RE: c2dx analogs for NSSelectorFromString, NSClassFromString, and respondsToSelector? | ||
|
Added by RongHong Huang over 1 year ago
hello, c++ is not a runtime progame language, and in cocos2dx, they are not supported either. about the translating of these methods, you could refer to the test just as: |
(1-1/1)