I have a single NSDictionary object which contains a large number of custom objects. The objects will either be of class B or of class C, both of which inherit from class A. If the objects are of type B, they will have an internal flag (kindOfCIsh) which will be used for future grouping.
How can I, at different times in my program, get ...
Say I have the following array of dictionaries:
{
{
isoName => en,
fullName => English,
localName => English
},
{
isoName => de,
fullName => German,
localName => Deutsch
},
{
isoName => fr,
fullName => French,
localName => français
}
}
How ...
I have a feeling that this is stupid question, but I'll ask anyway...
I have a collection of NSDictionary objects whose key/value pairs correspond to a custom class I've created, call it MyClass. Is there an easy or "best practice" method for me to basically do something like MyClass * instance = [ map NSDictionary properties to MyClass...
I can test for the presence of a key in an NSDictionary in two ways:
BOOL containsKey = [[dictionary allKeys] containsObject:foo];
BOOL containsKey = ([dictionary objectForKey:foo] != nil);
which method is faster? Please show your work.
...
I'm trying to add multiple instances of UIImageView(s) to an NSMutableArray of NSMutableDictionar(ies).
I am doing this, to be able to go back and pull out the UIImageView reference, to change the position of these images.
It seems that, when I pull the info out of the Dictionary, that it only returns a null pointer...
Any suggestions...
Hi,
I fetch a JSON array from a web service with touchJSON.
Which looks like this:
[{"icecream": {"title": "Banana"}}, {"icecream": {"title": "Strawberry"}}]
I'm not able to parse this into a NSDictionary, because
touchJSON doesn't support JSON arrays.
How do I get my JSON array into a NSDicitionary?
Regards
...
I need to reorder a plist (an array of dictonaries) by Key value.
In this example content I'd like to order by the value for the key Name (Matt, Joe):
<dict>
<key>Name</key>
<string>Matt</string>
<key>Details</key>
<string>Me</string>
</dict>
<dict>
<key>Name</key>
<string>Joe</string>
<key>Details</key>
...
I'm sure I'm missing something obvious here in a simple iPhone program I'm trying to write, but the code seems so basic that I can't see what's wrong.
I'm trying to use an NSMutableDictionary to store a list of classes and their associated save file names. In the header file I declare the dictionary
@interface ClassList : UITableViewC...
I have a servlet that serves up a plist XML file. What's the best way to slup this into an NSDictionary? I have this basically working with:
NSDictionary* dict = [ [ NSDictionary alloc] initWithContentsOfURL:
[NSURL URLWithString: @"http://example.com/blah"] ];
But then I have no control over the timeout; I'd rather not have m...
NSDictionary is good for key-value pairs, by what data structure is best for when you have three values? Is is best to create a class for those 3 values, and then let each object in an array contain instances of that class?
To be specific: The data structure, let's call it Person, I envisage has three values:
(NSString)name, (int)age, ...
I'm using json-framework to create a NSDictionary out of a JSON response. That much works wonderfully.
Now, within this JSON payload are one or more objects - let's call them X. Sort of like this in XML:
<OBJECTS>
<X>
...
</x>
<X>
...
</X>
<X>
...
</X>
</OBJECTS>
When I look in the aforementioned NSDictionary ...
i create a array from a NSDictionary object:
NSarray *myarray=[dictionary allValues];
however the return array object at index is not according to the dictionary, for instance the first object in dictionary was "title", but in my array it returned contact number, why this happended and how to prevent?
also when i set the object to m...
I have a Dictionary of Dictionaries which is being returned to me in JSON format
{
"neverstart": {
"color": 0,
"count": 0,
"uid": 32387,
"id": 73129,
"name": "neverstart"
},
"dev": {
"color": 0,
"count": 1,
"uid": 32387,
"id": 72778,
"name": "dev"
},
"iphone...
Hi,
I am new to Objective-C and I have no clue why this code is not working:
NSMutableDictionary *bookmarks = [NSMutableDictionary dictionaryWithCapacity:(NSUInteger) 4];
[bookmarks setObject:@"Stanford University" forKey:[NSURL URLWithString:(NSString *) @"http://www.stanford.edu"]];
[bookmarks setObject:@"Apple" forKey:[NSURL URLW...
What is the difference between objectForKey and valueForKey?
I looked both up in the documentation and they seemed the same to me.
...
My question is why does it output the last 4 lines in the log(see below)...those objects are part of the dictionary printed earlier in the log & should not be located at the end of the array? I am missing something fundamental here... thx
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
[NSURL URLWithString: @"www...
When I was using an NSArray, it was easy:
NSArray *array = ...
lastIndex = INT_MAX;
...
int randomIndex;
do {
randomIndex = RANDOM_INT(0, [array count] - 1);
} while (randomIndex == lastIndex);
NSLog(@"%@", [array objectAtIndex:randomIndex]);
lastIndex = randomIndex;
I need to keep track of the lastIndex because I want the feeling o...
Hi everyone, I would appreciate some help with something I working on and have not done before now and having some proplems because I don't think I understand exactly how to do this. What I'm wanting to do i'm sure is simple to most all of you and will be to me as soon as I do it the first time correctly....anyway.... I have a tableview ...
I want to programatically create a dictionary which feeds data to my UITableView but I'm having a hard time with it. I want to create a dictionary that resembles this property list (image) give or take a couple of items.
I've looked at "Property List Programming Guide: Creating Property Lists Programmatically" and I came up with a small...
NSMutableDictionary *bookmarks = [NSMutableDictionary dictionary];
[bookmarks setObject:[NSURL URLWithString:(NSString *) @"http://stanford.edu"] forKey:
@"Stanford University"];
[bookmarks setObject:[NSURL URLWithString:(NSString *) @"http://apple.com"] forKey:
@"Apple"];
[bookmarks setObject:[NSURL URLWithString:(NSString *) @"http://...