Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

hiddenpremise

macrumors regular
Original poster
Hi, I've got a plist file with jpeg photo data in it. I need to get that photo out. I can read the plist file into an NSDictionary and can access the object at the key "jpegphoto". The problem is that the object returned is an NSCFArray that I have no idea how to work with. I can print it and I see a nice stream of octets come out, but that's all I know how to do. How do I get this NSCFArray into NSData or a byte array?

The CFArray when passed to NSLog like so
Code:
NSLog(@"%@", [data_dictionary objectForKey:@"jpegphoto"]);
Spits out hundreds of line similar to
Code:
5ed15ee6 df44b2ff 00899699 0dd23b58 dccdcadc 6c8d04e1 8b3e1940 af76953e 7c0e1b56
I know that it is a CFArray b/c I did
Code:
NSLog(@"%@", NSStringFromClass([[data_dictionary objectForKey:@"jpegphoto"] class]));
And got back
Code:
NSCFArray
Thanks
 
Last edited:

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Where is this plist coming from? If the "jpegphoto" was an NSData that'd be pretty obvious how to load it, but since it's an array it's unclear what the array is holding.

Can you loop through the array and print out the class name of each of its objects?
 

Sydde

macrumors 68030
Aug 17, 2009
2,552
7,050
IOKWARDI
From what you are showing, it looks like an array of either NSNumbers or NSStrings. You might try concatenating the values in the array together to form a block of data that NSImage would be able to convert.

If it is NSNumbers, you should be able to just walk a pointer through a data block for each number. If it is hex-encoded strings, you would have to use a NSScanner to convert them to numbers (-scanHexInt:).
 

chown33

Moderator
Staff member
Aug 9, 2009
10,740
8,416
A sea of green
Spits out hundreds of line similar to
Code:
5ed15ee6 df44b2ff 00899699 0dd23b58 dccdcadc 6c8d04e1 8b3e1940 af76953e 7c0e1b56

If that's the start of the data, I have no idea what it represents. It's not a JFIF (JPEG File Interchange Format, aka JPEG file).
http://en.wikipedia.org/wiki/JPEG_File_Interchange_Format

If that isn't the start of the data, then post the starting line of data.

How do you know it's JPEG data? If you told us where the data came from, we might have better suggestions.
 
Last edited:

balamw

Moderator emeritus
Aug 16, 2005
19,366
979
New England
I know it is jpeg data because the key in the plist is called "jpegphoto". And what I posted is just the beginning. I shortened it b/c that actual data is very long. Thanks!

It could still be JPEG data, but without the JFIF/EXIF headers or with the headers later in the stream. If so you might have trouble interpreting it without necessarily knowing the image's dimensions, etc...

Do you find 0xFFE0????4A46 anywhere in the stream?

B
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.