Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
576 views
in Technique[技术] by (71.8m points)

iphone - What is the class NSCFNumber in iOS 4.1?

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...