일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- C#
- PDA
- C/C++
- M8200
- EUC-KR
- 와이브로
- Font
- docker
- 데이터 전달
- VS2008
- php
- net
- plcrashreporter
- 자바스크립트
- 블루투스 헤드셋
- GDI
- .net
- ClickOnce
- protobuf-c
- 기념일관리
- phpmailer
- Antialiasing
- 크래시로그
- MFC
- crashlog
- JavaScript
- API
- self-signed ssl
- 한 번만 실행
- 설치제거
- Today
- Total
~☆~ 우하하!!~ 개발블로그
[NSString stringWithString:nil] 의 리턴값은 어떻게 될까? 본문
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 |