I have written code as given below
strPageText=[NSString stringWithFormat:@"%@%@",strPageText,data];
This is in loop. it gives me a memory leak error.
I have written code as given below
strPageText=[NSString stringWithFormat:@"%@%@",strPageText,data];
This is in loop. it gives me a memory leak error.
Like Vladimir said the code does not have a memory leak.
But you are using factory method stringWithFormat to create your string. So the object is autoreleased. And if you are running this in a loop, you must be getting a lot of autoreleased objects. So for better memory management your code should handle allocating and releasing the memory of your objects:
strPageText=[[NSString alloc] initWithFormat:@"%@%@",strPageText,data];
and the release the string at the end of the loop before next iteration.
[strPageText release];