Question #1
Will NSStringFromCGPoint() return an autorelease object or does the object needs to be released?
Question #2
When you have a property : @property (nonatomic, retain) NSString *someString;
And you set it like so: self.someString = [[[NSString alloc] initWithString:@”Something”] autorelease];
Is this:
[someString release];
someString = nil;
equal to
self.someString = nil;
I haven’t checked that one specifically, but by convention those sorts of functions return autoreleased objects. You might be able to test this yourself by setting up a minimal, non-ARC project and calling
-retainCounton what you get out of the function, but I’m not sure. (And in general,retainCountisn’t something you want to use.)Yes. The synthesized setter looks something like:
So, whether you call it explicitly or using the dot notation, the old value gets released (and the underlying ivar gets set to
nilor whatever you pass in).Also, I’m not sure if you were just doing it for a random example, but you don’t have to wrap a string literal in memory management code to pass it to the property accessor. (That is,
self.someString = @"Something"is fine.)