i got this piece of code:
- (void)postToWall {
FBStreamDialog *dialog = [[FBStreamDialog alloc] init];
dialog.userMessagePrompt = @"Un tuo commento:";
dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"Bla: %@\"", facebookName];
[dialog show];
[dialog release];
}
the first time it get executed it works fine, no problem. But if I post or skip and then I post again I got an EXC_BAD_ACCESS, due to facebookName. The console shows no error, I found it via DebugConsole. I really don’t know why this happens, can someone help?
EDIT: SOLVED!!!
In other parts of the code, I accessed the facebookName string by its name. This apparently leads to crash, so I synthesized it and then accessed it by “self.facebookName”.
Thank you.
You should show contextual code regarding
facebookName.I think maybe it is being released by the time you use it again. Just to be safe, you can try doing
[facebookName retain]at the beginning of the method and then[facebookName release]at the end, to signify that you need to hold on to the object to do some work.Yep, using the synthesized property automatically retains objects when you assign them (provided you have the usual,
(nonatomic, retain)). Before, it wasn’t retaining so by the time you used it again a couple times, you would get EXC_BAD_ACCESS since it no longer existed (was released by then, cause again, it wasn’t retained).