Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mkristain

macrumors regular
Original poster
Aug 18, 2011
115
0
hello,

in my for loop i check the condition and format a string and set this string on a label,so here memory is increase.
Code:
NSString* str=@"";
		for(int j=0; j<512; j++)
		{
			str=[NSString stringWithFormat:@"Current Loop Value%d",j];
[_test_label setStringValue:str];
		}
is there any other method to format the string set on label without increasing memory.

thanks in advance.
 
We've been here before with you. This code is not real world. Please, stop wasting our time on such non-sense.

BTW, no.
 
Last edited:
hello,

in my for loop i check the condition and format a string and set this string on a label,so here memory is increase.
Code:
NSString* str=@"";
		for(int j=0; j<512; j++)
		{
			str=[NSString stringWithFormat:@"Current Loop Value%d",j];
[_test_label setStringValue:str];
		}
is there any other method to format the string set on label without increasing memory.

thanks in advance.

Thank you for your question.
We appreciate your questions.
We would also appreciate if you actually listened to any advice given.
 
You could set up an autorelease pool around the loop, or even inside the loop. The loop is useless, though, so you can really just set this using 511. Also, assigning @"" to your pointer is unnecessary. Initializing to nil is more "normal".

-Lee
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.