iOS 4.1中的NSCFNumber类是什么? [英] What is the class NSCFNumber in iOS 4.1?

查看:630
本文介绍了iOS 4.1中的NSCFNumber类是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 4.1上成功从iPhone相机获取图片后,您可以使用密钥

  @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说Class:NSCFNumber



<我需要比较这个对象的值来确定如何继续。横向是1或3,肖像是6或8.我不确定要键入方向或调用什么。 NSNumber和NSInteger总是告诉我,我正在使用没有强制转换的指针制作整数。



感谢您的时间!

解决方案

这告诉您方向是 NSNumber 的实例。从技术上讲, NSCFNumber NSNumber 的私有子类,但这是一个实现细节,您不必担心关于。要获得整数值,您可以调用

  [orientation integerValue] 


After successfully acquiring a picture from the iPhone camera on iOS 4.1, you can use the key

@"UIImagePickerControllerMediaMetadata"

to return information about the picture. One of the keys in that dictionary is

@"Orientation"

From my experimentation, Portrait and Upside down are 6 and 8 respectively, and the landscapes are 1 and 3. Look at this code:

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

The NSLog says "Class: NSCFNumber"

I need to compare this object's value to determine how to proceed. Landscape is 1 or 3, portrait is 6 or 8. I'm not sure what to type orientation as or what to call on it. NSNumber and NSInteger always tells me I'm making integers from pointers without casts.

Thanks for your time!

解决方案

This is telling you that orientation is a instance of NSNumber. Technically, NSCFNumber is a private subclass of NSNumber, but that is an implementation detail which you don't have to worry about. To get the integer value you would call

[orientation integerValue]

这篇关于iOS 4.1中的NSCFNumber类是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆