Incorrect decrement of the reference count of an object that is not owned at this point by the caller

假如想象 提交于 2019-12-03 03:57:16

Since you are reassigning the imageString variable, the reference to the original object is lost. Why allocate an empty string anyway? Just change the code to

NSString *imageString = [[[storiesArray objectAtIndex:i] objectForKey: @"image"]
   stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

and remove the [imageString release] and you're good to go.

Don't track reference counts as a way into understanding memory management. It's only going to confuse you. Things manipulate your objects' reference counts from deep in the framework, and if you watch those numbers jump around for (apparently) no reason, you'll just go insane and post a series of increasingly crazy questions here, which we'll then have to deal with. Believe me--we've seen it before.

So just ignore the reference count number, and make sure you're retaining and releasing objects properly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!