NSLog(@"NSNumber.intValue = %d", (@98765).intValue);
NSLog(@"NSString.intValue = %d", @"01234".intValue);
NSLog(@"NSNumber.stringValue = %@", (@98765).stringValue);
NSLog(@"NSString.stringValue = %@", @"01234".stringValue);
こうすると、最後の行でエラーが出る。
Property 'stringValue' not found on object of type 'NSString *'
エラーが出るならいいけど、
NSDictionary *dic = @{ @"num": @98765, @"str": @"01234" };
NSLog(@"NSNumber.intValue = %d", [dic[@"num"] intValue]);
NSLog(@"NSString.intValue = %d", [dic[@"str"] intValue]);
NSLog(@"NSNumber.stringValue = %@", [dic[@"num"] stringValue]);
NSLog(@"NSString.stringValue = %@", [dic[@"str"] stringValue]);
なんてことをしていると、
NSNumber.intValue = 98765
NSString.intValue = 1234
NSNumber.stringValue = 98765
-[__NSCFConstantString stringValue]: unrecognized selector sent to instance 0xe65284
NSInvalidArgumentException
落ちる。
いつの間にか
落ちなくなってる。(Property〜のエラーは出る)
iOS 13から?
NSNumber.intValue = 98765
NSString.intValue = 1234
NSNumber.stringValue = 98765
NSString.stringValue = 01234