This is a (very) simplified version of my iPhone code :
@interface x {
NSString * name1;
NSString * name2;
}-init {
name1 = @””;
name2 = @””;
}-(void) a {
Foo * foo = [Foo alloc];
name1 = @”uhuh”;
name2 = [foo bar]; // return a (NSString *)
[foo release];
}-(void) b {
NSLog(@”%@”, name1); // it works
NSLog(@”%@”, name2); // there I get an EXC_BAD_ACCESS…
}
Why I have this problem ? And how can I solve it ?
Thanks !
Edit: I juste solve the problème, I forgot a “retain”…
I was getting an EXC_BAD_ACCESS error yesterday. It turned out I was calling
releaseon an object which resulted in it being deleted, then I tried to use it.You’re not calling
releaseon anything you’re not supposed to are you?Just a friendly reminder: if you don’t call
allocorretainon an object, you don’t callrelease. With the code you have provided, it doesn’t appear this is the problem. But I wanted to point this out just in case.