views:

66

answers:

2

I'm developing iphone app. Yesterday I updated my xcode to to newest version and clean build folders (deleted it), then created new class (nothing special):

@interface EnemyFactory : NSObject {

}
+(Enemy *)properReferenceForName: (NSString *) name;
@end

Implementation is trivial and not important. What is happening now: I've got sth like this:

Enemy *tempEnemy = [EnemyFactory properReferenceForName:@"enemyname"];

But code never reaches function properReferenceForName. I've got EXC_BAD_ACCESS with stack like this:

0   0x02a95e2b in realizeClass
1   0x02a96dad in _class_getNonMetaClass
2   0x02a90eb0 in _class_initialize
3   0x02a961f6 in prepareForMethodLookup
4   0x02a8f6c9 in lookUpMethod
5   0x02a8f836 in _class_lookupMethodAndLoadCache
6   0x02a9dad3 in objc_msgSend
7   0x0000595d in -[GameLayer newEnemy:] at GameLayer.m:368

Before update. Xcode gives no warning or error. Symbols are declared. What is interesting though is that: everything goes fine, when I debug step by step whole invocation... I'm stuck with it for 8 hours.

Update 1:

[[EnemyFactory alloc] init] throws the same error

Update 2:

When I do this: [EnemyFactory alloc] in some master class during initialization everything goes in flying colours.

A: 

Take a look at GameLayer.m line 368 something to do with [GameLayer newEnemy:]. I don't see anything wrong with the code you posted.

Jordan
There is invocation of method which use line mentioned in post with EnemyFactory.
vitotao
A: 

If the code is never reaching your class method, the problem is where the stack trace starts, i.e. [GameLayer newEnemy:]

Look for objects that you may need to retain but are not retaining within the newEnemy method.

Remover
properReferenceForName is class method for EnemyFactory. How could I alloc it (class object?)? I'm relatively new to obj-c, mayby I'm missing something.EnemyFactory creates only objects of given class by string name.Referencing you mean #import it? Yes I do.
vitotao
sorry, i lost my mind for a moment. you don't need to alloc a class object of course. updated answer.
Remover