nsdictionary

Failing to read array data from a plist - (null) ejected.

Hey! I am currently trying to get data out of a plist. It basically looks like that: plist called 'woerter' -> Root key of type Dictionary -> woerter key of type Array -> various Items of type String with string Values When I now try to read a random string from it, I only get a (null) expression NSString * path =...

Best way to sort an NSArray of NSDictionary's?

Hi, I'm struggling with trying to sort an array of dictionarys. My dictionaries have a couple of values of interest, price, popularity etc. Any suggestions? ...

Cocoa's NSDictionary: why are keys copied?

All objects used as keys in NS(Mutable)Dictionaries must support the NSCopying protocol, and those objects are copied when they're used in the dictionary. I frequently want to use heavier weight objects as keys, simply to map one object to another. What I really mean when I do that is effectively: [dictionary setObject:someObject forKe...

Accessing Instance Attributes from Secondary Thread (iPhone-SDK)

I have a class with an NSDictionary attribute. Inside this class I dispatch another thread to handle NSXMLParser handling. Inside my -didStartElement, I access the dictionary in the class (to compare an element found in the XML to one in the dictionary). At this point I get undefined results. Using NSLog (I'm not advanced in XCode debug...

iPhone Simplest Communication between Threads

I have an iPhone app with a secondary thread to handle XML parsing. Inside some of those methods, I need to reference dictionaries (for look up, not modification) created and populated in the main thread. Apple's documentation indicated to me that global variables might be the best way to accomplish this. I'm just now sure what the impl...

UIPickerView with NSDictionary

I am a .NET programmer and new to Objective C. I am trying to make a UIPickerView which acts like a .NET dropdownlist. User sees the list of text and selects one and the selected value (which is the ID) is used in code. I have been browsing for almost half a day trying to figure this out. I could add a regular PickerView with list of...

Saving a single NSMutableDictionary in a plist

I have one dictionary I need to save into a plist. The paletteDictionary always returns nil: - (void)saveUserPalette:(id) sender { [paletteDictionary setObject:matchedPaletteColor1Array forKey:@"1"]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirector...

passing argument 1 from incompatible pointer type

Why does this code...: NSDictionary *testDictionary = [NSDictionary dictionaryWithObjectsAndKeys:kABOtherLabel, @"other", kABWorkLabel, @"work", nil]; // There are 9 more key-value pairs that i've omitted here. throw this warning: warning: passing argument 1 of 'dictionaryWithObjectsAndKeys' from incompatible pointer type Incidental...

NSData is being truncated when stored in sqlite database.

I am attempting to store NSMutableDictionaries as a blobs in sqlite, by first converting it into NSData via either NSPropertyListSerialization or NSKeyedArchiver. When I store the blob, the NSData object's length is in the thousands (KB range). When I get it back, it's been truncated to 10 bytes. When I check the DB through SQLite Brow...

Remove duplicates in NSdictionary

Is there a way to remove duplicate (key-value) pairs from NSDictionary ? EDIT: My description was misleading, I have duplicate pairs e.g. key1-value1 key1-value1 key2-value2 key1-value1 etc.. ...

How to process an SQLite row (with categories) to an UITableCellView (with sections)

Hi guys! Currently I'm receiving a list of objects from a SQLiteDB by using: -(NSMutableArray*) getMoreForObjectIdByCategoryId:(NSInteger) itemId: (NSInteger) categoryId On the ViewController Side, I'm using the (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { in combination w...

NSMutableDictionary is adding quotes to keys and values - why?

I'm trying to add some additional key/value pairs to an NSMutableDictionary, using: Tag *tag1 = [results1 objectAtIndex:0]; [resultsDict setObject:[tag1 retrieveTextUpToDepth:1] forKey:@"image_url"]; Tag *tag2 = [results2 objectAtIndex:0]; [resultsDict setValue:[tag2 retrieveTextUpToDepth:1] forKey:@"majority"]; This adds the k/v pa...

Looking for an elegant way to store one-to-many relationship in coredata when order is important

I've been trying to come up with a way to solve my problem, but every solution I can think of is messy and makes me want to retch. I have a one-to-many relationship, consisting of a Team object that can have many Member objects. When I built my data model using Xcode, I was given the default NSSet in which to store the member objects, ...

Is NSDictionary key order guaranteed the same as initialized if it never changes?

I've run into the same problem as found in this question. However, I have a follow-up question. I seem to be in the same situation as the original asker: I have a plist with a hierarchy of dictionaries that define a configuration screen. These are not mutable and will stay the same throughout the application. Since the original discussio...

iPhone SDK: NSUserDefaults or NSDictionary?

Compare the following: using NSUserDefaults saving it with synchronize using NSDictionary saving it with writeToFile in the app Documents folder What are the differences? Personally, I prefer to mantain different NSDictionary organized by topic rather than use a single NSUserDefaults. Am I thinking something wrong? Thanks ...

writing NSDictionary to plist in my app bundle

Hi I'm trying to write an NSDictionary to a plist but when I open the plist no data has been written to it. From the log my path looks correct and my code is pretty standard. Any ideas? NSArray *keys = [NSArray arrayWithObjects:@"key1", @"key2", @"key3", nil]; NSArray *objects = [NSArray arrayWithObjects:@"value1", @"value2", @"value3...

Xcode Interface builder: How to connect NSObjectController.content to outlet of file's owner?

I have a nib file that contains a window/view and an instance of NSObjectController. I programatically load the window in the nib setting "self" as owner. "self" is my custom classs that defines an IBOutlet: an NSDictionary called settings. I now want to have that dictionary as content for the object controller. Is there a way to connec...

Casting warnings in methods with variable arguments

Sorry if the question isn't correct, I'm very new in Objective-C. I understand why this code throw the Warning: "warning: passing argument 1 of 'initWithObjectsAndKeys:' makes pointer from integer without" NSDictionary *dictNames = [[NSDictionary alloc] initWithObjectsAndKeys: 3, @"", 4, @"", 5, @"",nil]; Keys and Value...

Loading data from a dictionary of dictionaries into an array in Objective C for an iphone app

I have a UINavigationController consisting of a tableview I want to load some data into. I have a dictionary plist containing Dictionaries for each Train Line which in turn have dictionaries for each station with the relevant information along with one string lineName. I need to collect the station Names keys and add them to an array to...

When is NSCopying needed?

I know it's needed if your object will be used as a key in an NSDictionary. Are there any other times like this that NSCopying is required? If I think I don't need my model objects to conform to NSCopying, am I probably wrong? ...