I have this code that simply returns Date date as a string formatted:
+(NSString*) getTodayString_YYYY_MM_DD {
NSDate * today = [NSDate date];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd"];
return [[formatter stringFromDate:today] autorelease];
}
With tools, I don't get a memory leak, but when I parse, Xcode says:
Object sent -autorelease too many times
If I understand correctly, I have to manually publish the formatter, because I create it using 'alloc', but I can not free it, because I need to return the value, so I add auto-advertising.
How can I improve this?
thank,
g.
source
share