views:

36

answers:

2

Hello,

I am in a strange dilemma . I have a class clsA which has some methods .I am creating instance of ClsA in other class and accessing methods of clsA . I have declare object of clsA in header file and I m writing these two lines simultaneoulsy .

clsAobj = [[clsA alloc] init];
[clsAobj someemethod];

The problem is that while Debugging after execution of 1st line Debugger shows memory allocated to clsAobj but after execution of second line, allocated memory is lost and becomes 0x0 . This is true while accessing any method of ClsA .

Can anybody help me in atleast understanding this dilemma ? Thanks .

A: 

It's hard to say what's happening without seeing how clsA and someemethod are implemented. My best guess is that the init or alloc method of clsA is returning nil (making clsAobj nil after the first line and not the second) but without seeing more code it's going to be tough to give you more detailed feedback.

Mattia
A: 

Are you debugging optimized code? That could explain what you are seeing; the compiler has optimized away the reference because it is no longer needed.

Alternatively, did you return self in your init method?

bbum