I receive a SIGABRT when I try to get a non-null variable. Code:
NSLog(@"%@", appDelegate.xmlData.magDictionary);
for (Magazine *ibb in appDelegate.xmlData.magDictionary) {
NSLog(@"%@", [ibb title]);
}
Output:
{
1 = "<Magazine: 0x6c8fe10>";
2 = "<Magazine: 0xf168d00>";
3 = "<Magazine: 0xf169f50>";
4 = "<Magazine: 0xf16b6d0>";
5 = "<Magazine: 0xf170490>";
6 = "<Magazine: 0xf1716c0>";
7 = "<Magazine: 0xf172a80>";
8 = "<Magazine: 0xf173f10>";
}
and SIGABRT on NSLog(@”%@”, [ibb title]);
The Magazine model: @synthesize title, key, teaser, tags, items, progressBar;
According to the comments, it appears that you do wrong in your
Magazineinitializer.Using
retainmode for the property doesn’t really matter, but I would have usedcopyinstead for string.Anyway, the
titlestring coming fromoriginalMagisn’t retained, or copied at all when assigned to thetitleivar of yourMagazine, thus I bet it is deallocated before you try to print any value, causing the crash.Another point, doing :
generates a memory leak (and you still don’t retain the original
title).Rewrite the initializer like so :
and this should solve your app crash.