Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 488
Daddy Avatar asked Dec 05 '10 02:12

Daddy


2 Answers

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]
like image 79
Pete Rossi Avatar answered Nov 07 '22 23:11

Pete Rossi


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.

like image 45
Shaggy Frog Avatar answered Nov 08 '22 00:11

Shaggy Frog