什么是iOS 4.1中的类NSCFNumber?

在iOS 4.1上成功从iPhone摄像头获取图片后,可以使用该button

@"UIImagePickerControllerMediaMetadata" 

返回关于图片的信息。 该字典中的一个关键字是

 @"Orientation" 

从我的实验中,肖像和颠倒分别是6和8,风景是1和3.看看这个代码:

 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { NSDictionary *metaData = [info objectForKey:@"UIImagePickerControllerMediaMetadata"]; id orientation = [metaData objectForKey:@"Orientation"]; NSLog(@"Class: %@",[orientation class]); 

NSLog说“类:NSCFNumber”

我需要比较这个对象的值来决定如何继续。 景观是1或3,人像是6或8.我不知道要input方向或者要调用什么。 NSNumber和NSInteger总是告诉我,我是从没有强制转换的指针进行整数。

谢谢你的时间!

这是告诉你,方向是一个NSNumber的实例。 从技术上讲, NSCFNumberNSNumber一个私有子类,但是这是一个你不必担心的实现细节。 获得整数值,你会打电话

 [orientation integerValue] 

NSNumber是一个类集群。 NSCFNumber是该集群中类的具体“私有”实现。 像使用NSNumber对象一样使用返回的值。