received memory warning. level 1

会有一股神秘感。 提交于 2019-12-01 01:51:14

You're creating a new string with every call to setchallenge = [[NSString alloc]....

Should be:

//For Challenge Text
NSString *challange = [theQuiz objectAtIndex:row+8];
Challengetext.text = [NSString stringWithFormat:@"%@" , challange];

stringWithFormat returns an auto-released string, which will get deallocated next time the auto-release pool is drained.

joe

Since you alloced memory, you need to release it as well. Anytime you use alloc, copy or new, remember to always release. Its not a good idea to release everything only at dealloc. Release objects when you are done with them. For example:

 setchallange = [[NSString alloc] initWithFormat:@"%@" , challange];//Memory leak here
 Challengetext.text = setchallange;
 [setchallange release]

Also checkout out the iOS memory management guide. I'm sure it will help.

May be for some object you allocating more than one times and release it once. just check it out I hope it will be solve.

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