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
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.
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
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.