Current project got lots of data in NSArrays and NSDictionaries. Nothing against them, extremely useful data structures. Just got to finetune my hammer a bit (since hammer is what I got and thus everything looks like a nail).
So how do you find a certain NSDictionary from NSArray containing a requested key? Two easy ways here:
Showing posts with label NSDictionary. Show all posts
Showing posts with label NSDictionary. Show all posts
Friday, January 13, 2012
Find NSDictionary in NSArray with Certain Value
Labels:
NSArray,
NSDictionary,
NSIntegerMax,
NSNotFound,
search
Thursday, December 8, 2011
How to Sort NSDictionary
Let's get this straight: you cannot sort NSDictionary.
Dictionary is a collection of keys and their objects without an order, therefore you cannot change that non-existing order. You can sort only array data types, since they are basically ordered lists.
There are still good news. You can get all keys from any dictionary as an array and sort them. Usually this is enough.
Dictionary is a collection of keys and their objects without an order, therefore you cannot change that non-existing order. You can sort only array data types, since they are basically ordered lists.
There are still good news. You can get all keys from any dictionary as an array and sort them. Usually this is enough.
Friday, January 21, 2011
What is Inside UIImagePickerControllerMediaMetadata
Been debugging UIImagePickerController too many times, so it's time for some tips. The most easy way to see what's in there somewhere. Also including a sample output.
Labels:
debug,
Exif,
NSDictionary,
NSLog,
photo,
TIFF,
UIImagePickerController,
UIImagePickerControllerMediaMetadata,
UIImagePickerControllerOriginalImage,
UIImagePickerControllerReferenceURL
Sunday, January 16, 2011
How to Check if iOS Supports Class, Method or Keyword
iOS is getting fragmented. More devices to support with major iPhone hardware differences (0-2 cameras, no telephony - 3G - CDMA), screen resolutions (original, double, iPad) and especially more older operating system versions out in the wild.
To reach as many users as possible you have to check whether something exists before you try to use it. Customizing code based on iOS version number is possible, but there are other ways to do it.
To reach as many users as possible you have to check whether something exists before you try to use it. Customizing code based on iOS version number is possible, but there are other ways to do it.
Labels:
Class,
conformsToProtocol,
fragmentation,
iOS4,
NSClassFromString,
NSDictionary,
NSString,
objectForKey,
protocol,
respondsToSelector,
selector
Tuesday, February 2, 2010
How to Use Struct in NSDictionary
Thought I wanted to use a NSDictionary for some reason, but after all the trouble didn't. However it was quite a challenge to make it work, so I'll post here a code sample. Maybe it will be useful at some other time:
struct myStruct {
NSUInteger value;
NSString *s;
} myItem[2] = {
{ 1, @"test"},
{ 2, @"test2"}
};
NSDictionary *myDict = [NSDictionary dictionaryWithObjectsAndKeys:
[NSValue valueWithPointer:&myItem[0]], @"myKey1",
[NSValue valueWithPointer:&myItem[1]], @"myKey2",
nil];
Subscribe to:
Posts (Atom)