开发者

Strange NSNumberFormatter crash

The code is simple:

static NSNumberFo开发者_JS百科rmatter *numberFormatter = nil;

if (numberFormatter == nil) {
    numberFormatter = [[NSDateFormatter alloc] init];
    [numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
}

However, it crashes on the last line:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSDateFormatter setNumberStyle:]: unrecognized selector sent to instance 0x5c378d0'

How is it possible?


Because you created an NSDateFormatter, not an NSNumberFormatter.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜