Hi All, I know this is a problem with memory management, but I can't figure out how to solve it. I've got an object of class A. It's got one NSString instance variable. It's interface is as follows: @interface mapSymbol : A{ NSString *actionCall; } -(void) setActionCall: (NSString *)incoming; -(NSString *) getActionCall; and the implementation is -(void) setActionCall: (NSString *)incoming { actionCall = incoming; NSLog(@"Action call set to :%@", actionCall); } -(NSString *) getActionCall { NSLog (@"returning Action Call"); return actionCall; } I'm calling the getActionCall method from an object of class B. But, when I try to run any opertion on the returned NSString, I get the EXC_BAD_ACCESS error. Any ideas? The call from class B is NSString *tempString = [tempObject getActionCall];where tempObject is the class A object, stored in an array. I've been stuck on this for 2 hours, and can't figure it out. Any help would be appreciated.
You should really be using properties for this since your getters and setters don't do anything out of the ordinary. So get rid of the functions altogether and declare actionCall as a property then synthesize the getters and setters in your implementation. You probably need to be using retain for the property rather than assign since the initial value that you assign seems to be getting autoreleased and hence it is no longer in existence when you try and grab it again.
Exactly what I was going to say. Usually in ClassA, I would have something like: @property (nonatomic, retain) NSString* actionCall I also suspect you are not retaining the string, and it's getting auto released.
Exactly It is also worth noting that obj-c strings are objects and not primitives so they have to be memory managed in the same way that all objects do.