I have an NSDate category:
//Format date yyyy-MM-dd
- (NSString *)stringInInternationalStandardDateNotationFormat
{
//Setup the dateFormatter
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
//Format the dates
NSString 开发者_StackOverflow社区*result = [dateFormatter stringFromDate:self];
[dateFormatter release];
return result;
}
And wondered whether the instance method above is the best way forward or should I rather accept the date as a parameter in a class method?
I see no reason to make that a class method. If you did, you'd basically just be passing an explicit self with the same method body.
精彩评论