NSLog(@"result = [%@]", [NSString stringWithString:nil]);
결과는
crash!!
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPlaceholderString initWithString:]: nil argument'
그렇다면
[[NSString alloc] initWithString:nil] 의 결과값은?
역시 crash!!
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPlaceholderString initWithString:]: nil argument'
마지막으로
[NSString stringWithFormat:@"%@", nil] 은 어떨까?
result = [(null)]
안 죽는다...
결국
[NSString stringWithString:NSStringVariable] 을 사용하는 것보다는
[NSString stringWithFormat:@"%@", NSStringVariable] 을 사용하는 것이 좋고
[[NSString alloc] initWithString:NSStringVariable] 을 사용하는 것보다는
[[NSString alloc] initWithFormat:@"%@",NSStringVariable] 을 사용하는 것이 안정적이다.
'iPhone & Cocoa' 카테고리의 다른 글
iOS App - AdHoc 버전 배포하기 (0) | 2012.07.04 |
---|---|
iOS Back-End Framework : DevTong (0) | 2012.07.02 |
프로젝트 빌드 전 스크립트로 빌드넘버 증가시키기 (0) | 2012.03.31 |
크래시로그 남기기 (0) | 2011.04.06 |
UIApplication, UIApplicationDelegate 호출 순서 (1) | 2011.04.01 |