In C, something like the following would be a disaster (ie, a memory leak) because you're returning a pointer to memory that you will never be able to free:
NSString* foo()
{
return [NSString stringWithFormat:@"%i+%i=%i", 2, 2, 2+2];
}
Is that in fact totally fine in Objective-C since the memory that the returned pointer points to will be autoreleased? Even if it is OK, is it frowned upon for any reason? Any reason to prefer the C style, as below?
void foo(NSString ** modifyMe)
{
*modifyMe = [NSString stringWithFormat:@"%i+%i=%i", 2, 2, 2+2];
}