开发者

Class method or instance method with parameter for NSDate category?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜