objective c - Why is NSClassFromString returning nil or not in these two cases? -


i'm working cocosbuilder 2.1 , cocos2d-iphone 2.0. i've gotten cocosbuilder compile, , i'm having weird problem when using one-text-label example in project.

here's code in question, ccbreader.m line 823:

class class = nsclassfromstring(classname); if (!class) {     nslog(@"ccbreader: not create class of type %@",classname);     return null; } 

this fails text "could not create class of type cclabelttf". if change code this:

class class = nsclassfromstring(classname); if (!class) {     cclabelttf* templabel = [[cclabelttf alloc] init];     [templabel release];     nslog(@"ccbreader: not create class of type %@",classname);     return null; } 

it works. don't see else having problems cocosbuilder in spot, what's going on?

the weird thing change can affecting @ compiler level, because added code inside error segment, right?

because did not use cclabelttf @ in project, runtime did not load class you.

it works after did hack because project use cclabelttf class runtime load it.

to solve problem, add -objc linker flag, check details in following links

http://developer.apple.com/library/mac/#qa/qa1490/_index.html https://stackoverflow.com/a/2615407/642626


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -