지금까지 다룬 정수, 부동 소수점 수, long 같은 모든 숫자 형은 Objective-C 언어의 기본 데이터 형이었다. 다시 말해, 이것들은 객체가 아니었다. 그러므로 이것에 메시지 같은 것을 보내는 일은 불가능하다. 그런데 이런 형 값을 객체로 다뤄야 할 때가 있다. 이를 위해 Foundation Framework에서 NSNumber 클래스를 제공한다.
@NSNumber 생성과 값을 받는 메서드
생성 및 초기화 클래스 메서드 |
초기화 인스턴스 메서드 |
값을 받는 인스턴스 메서드 |
numberWithChar |
initWithChar |
charValue |
numberWithInt |
initWithInt |
intValue |
numberWithLong |
initWithLong |
longValue |
numberWithFloat |
initWithFloat |
floatValue |
numberWithDouble |
initWithDouble |
doubleValue |
numberWithBool |
initWithBool |
boolValue
|