received memory warning. level 1

前端 未结 3 1555

I am new to iPhone development. I am creating an application in which i need to create buttons and labels programmatically.
So I am doing this in .h file



        
相关标签:
3条回答
  • 2021-01-07 16:20

    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.

    0 讨论(0)
  • 2021-01-07 16:23

    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

    0 讨论(0)
  • 2021-01-07 16:40

    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.

    0 讨论(0)
提交回复
热议问题