开发者

Class method or instance method with parameter for NSDate category?

开发者 https://www.devze.com 2023-01-25 03:37 出处:网络
I have an NSDate category: //Format date yyyy-MM-dd - (NSString *)stringInInternationalStandardDateNotationFormat

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

精彩评论

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