nsdictionary

Getting string from NSDictionary nested in a plist file

Hi, I am trying to get a string out of a plist file that contains a nested dictionary. This is the plist: <dict> <key>DataPoints</key> <array> <dict> <key>source</key> <string>BloomBerg</string> <key>date</key> <date>2010-01-31T14:54:13Z</date> <key>value</key> ...

How can I store a UIImage in an NSDictionary?

How can I store a UIImage in an NSDictionary? ...

NSDictionary - Need to check whether dictionary contains key-value pair or not

Hello Every one. I just need to ask something as follow. Suppose I am having a dictionary. NSMutableDictionary *xyz=[[NSMutableDictionary alloc] init]; [xyz setValue:@"sagar" forKey:@"s"]; [xyz setValue:@"amit" forKey:@"a"]; [xyz setValue:@"nirav" forKey:@"n"]; [xyz setValue:@"abhishek" forKey:@"a"]; [xyz setValue:@"xrox" forKey:@"x"];...

How to Get the Direct Access Index for NSDictionary of NSDictionary

Here's the code: NSMutableDictionary *circuit_step = [NSMutableDictionary dictionary]; NSMutableDictionary *step_info = [NSMutableDictionary dictionary]; [step_info setObject: @"search" forKey: @"search-type"]; [step_info setObject: @"small" forKey: @"search-format"]; [step_info setObject: @"winter" forKey: @"...

Return value For NSDictionary On Simulator, iPhone

Hello there, I have some code which requires an iPhone to run. I do however want to test my app on the simulator. On the iPhone I use this to return a value: return [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:-1], @"number"]; I'm looking for something like this I THINK: - (NSDictionary *) data { #if TARGET...

iPhone - NSDictionary to NSArray with preserved order

I've got a couple dictionaries in a property list, that make up a menu system for my game, like so: New game Easy Normal Hard Load game Recent Older Options Game Sound etc.. Each item in this list is a dictionary. I use UINavigationController and UITableViews to display this menu system. When an item is ch...

How to update NSMutableDictionary ?

I have an NSMutableDictionary. NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:path]; I have to update an element in that dictionary. How i can do that ? Thanks in advance ...

releasing View Controller which are in Dictionary - in objective c

Hello ! Every on here. I was just confusing a little bit for the following issue. I have coding in my project as follow. I am adding view controllers' view to the each cell of table view. let me explain how... An array, like these NSMutableArray *arrTbl=[[NSMutableArray alloc] init]; NSMutableDictionary *dOne=[[NSMutableDictionary a...

Sorting NSDictionary

Hi, I was wondering if someone can show me how to sort an NSDictionary; I want to read it starting from the last entry, since the key is Date + Time and I want to be able to append it to an NSMutableString. I was able to read it using an enumerator but I don't get the results I want. Thanks ...

NSDictionary - Printing Array

Hi, This site is great I'm getting alot of replies , so I have tried to code what I had problems with before here it is NSMutableArray *sort = [NSMutableArray arraywithArray:[dic allValues]]; for(NSString *s in sort){ [Purchases appendString:[NSString stringWithFormat:@"%@",s]]; } textview.text = Purchases; The output's ord...

How to get key value from NSdictonary - iphone sdk

Hello, I use a api wich provides me data from the web. The data is in Json format, and is stored in a NSDictionary. Like this: SBJSON *parser = [[SBJSON alloc] init]; dict = [[NSDictionary alloc]init]; dict = [parser objectWithString:jsonArray error:nil]; Ggb console result for: po dict 1262 = { "feed...

Better alternative for checking existence of NSDictionary's key in NSArray?

Hi, I have an NSArray of NSDictionaries. I need to check if there's at least one occurrence of an object for a key of the NSDictionary in the NSArray. I do this by using int i; for (i=0;i< [myArray count];i++) { if ([[[myArray objectAtIndex: i] objectForKey: myKey] isEqualToString: myString]) { found = YES; break; ...

Better alternative for "data-only" Objective-C objects?

I run into design choices like this often and struggle a bit; I'm looking for some other perspectives. I often want to keep lists of, or pass around chunks of state that are basically just sets of values. The values tend to be primitive types: floats, NSTimeIntervals, CGPoints, etc. My first inclination is often to create C structures ...

Any alternatives to NSDictionary for unique keys AND unique values?

I'm in the middle of writing some Cocoa classes to parse ID3 tags from MP3 files. To make them as easy to use as possible, I'm allowing the option to request a tag by the actual ID3 frame id ("TCON", "TPE1", "TALB", etc.) or an equivalent word/phrase ("genre", "artist", "album", etc.) To store this data, currently I have a reference cla...

ERROR: Memory Leak, data formatters temporarily unavailable

I am developing a quiz app. I take questions from a xml file, parse it and display random questions. These are stored in NSdictionary and NSMutableArray. Also the app plays background music and sound for clicking of buttons(AVAudioPlayer). and vibration( AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)) In one particular functi...

NSDictionary to NSArray?

Hey all, i have a NSDictionary which looks like: { "Item1" = 2.4; "Item2" = 5.5; "Item3" = 15.6; } To use this Dictionary Items in a Table View i have to transfer it to a NSArray, am i right? So i try: NSDictionary *dict = [myDict objectForKey:@"items"]; for (id item in dict) { [_myArray addObject:[dict objectForKey:item]]; } ...

how to declare a global variable in Objective-C?

// MyClass.h @interface MyClass : NSObject { NSDictionary *dictobj; } @end //MyClass.m @implementation MyClass -(void)applicationDiDFinishlaunching:(UIApplication *)application { } -(void)methodA { // Here i need to add objects into the dictionary } -(void)methodB { //here i need to retrive the key and objects of Dictionary into a...

Fast Enumeration With an NSMutableArray that holds an NSDictionary

Is it possible to use fast enumeration with an NSArray that contains an NSDictionary? I'm running through some Objective C tutorials, and the following code kicks the console into GDB mode NSMutableArray *myObjects = [NSMutableArray array]; NSArray *theObjects = [NSArray arrayWithObjects:@"easy as 1",@"easy as two", @"Easy as Three"]; ...

Crash-proof NSDictionary

Hi, I'm looking to create a "crash-proof" NSDictionary as I'm using a JSON serializer that converts a server response into an NSDictionary. As as result, sometimes the key for the dictionary is not present. Currently, this will crash the application, however I'd rather an empty NSString was returned so I can display this in the interfac...

App crashes when I create a NSDictionary with integer as Object

Hello, Always when I try to set an integer as Object in a NSDictionary the program crashes without a message (nothing in the console). What is wrong in this code? : NSString *string = @"foo"; int number = 1; NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys: string, @"bla1", number, @"bla2",nil...