iOS 4.1 中的 NSCFNumber 类是什么?

发布于 2024-10-05 16:31:52 字数 729 浏览 7 评论 0原文

在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 总是告诉我我正在从指针生成整数而不进行强制转换。

感谢您抽出时间!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

趁年轻赶紧闹 2024-10-12 16:31:52

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

[orientation integerValue]

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]
做个ˇ局外人 2024-10-12 16:31:52

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

NSNumber is a class cluster. NSCFNumber is a concrete, "private" implementation of a class in that cluster. Just use the returned value like you would an NSNumber object.

驱逐舰岛风号 2024-10-12 16:31:52

如今(2022)该方法已更改名称,您需要将其转换为 NSNumber 才能使用它,如下所示:

[((NSNumber *) orientation) intValue];

如果您想在 OutputConsole 上打印它,则需要使用 %d 而不是 %@,例如:

NSLog (@"%d", [((NSNumber*)  orientation) intValue] );

Nowadays (2022) the method has changed the name, and you needed to cast it to NSNumber before you can use it, like this:

[((NSNumber *) orientation) intValue];

And if you want to print it on OutputConsole, you need to use %d instead of %@, e.g.:

NSLog (@"%d", [((NSNumber*)  orientation) intValue] );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文