I was wondering can you please let me know about the following two scenarios which are almost alike but with little and bigger objects.
Scenario 1:
In the following code:
NSString *iAmAstring;
for(int i = 0; i < 100000;i++)
{
NSLog(@"INT VALUE: %d", i);
iAmAstring = [NSString stringWithFormat:@"%d", i];
NSLog(@"STRING VALUE: %@", iAmAstring);
}
I have been told since I have ARC turned on there is no implications with doing the above massive loop and inside it for every loop run I am allocating and initialising a string pointer. Because I have been told its too small and won't matter, and ARC can handle it. But not to do it with bigger objects. I am originally from C# background and I am used to setting even my string at the end of loop to null, but here you cannot release it at the end of loop cause ARC will complain and I have been told if I set it to nil at the end of loop I would be creating more work for ARC and I am not really doing things right and am creating zombie code. Can some one clarify what they would do to the object they are allocating, initialising in a massive loop thats small in memory size (preferably the string I have used) with ARC turned ON, at the end of loop?
Scenario 2:
The same as above but assume now NSSTRING thats being used above is now another object that is big in size. Here I would obviously allocate & initialize it before the loop and then use it in the loop by setting it, but how would I again do some things to it at the end of the loop to kinda free it, so once again ARC turned ON?
Thanks in advance.