nsdictionary

fast enumeration for NSDictionary instance ordered by the key

≡放荡痞女 提交于 2019-12-12 11:34:24
问题 Overview I am using fast enumeration to iterate through an NSDictionary instance I expected the NSDictionary instance to be enumerated based on the ascending order of the key but that doesn't seem to be the case What I want to do: I want to be able iterate through the NSDictionary instance in the ascending order of the key using fast enumeration Note: Pls see expected output vs actual output Questions Am i making a mistake with my implementation ? Does NSDictionary's fast enumeration

Comparing NSMutableArray Elements for Values

℡╲_俬逩灬. 提交于 2019-12-12 09:08:53
问题 I am looking for a way to compare the contents of two NSMutableArray objects. Both arrays are filled with NSMutableDictionaries which were allocated separately but occasionally contain the same data. Simplified Example: NSMutableArray *firstArray = [[NSMutableArray alloc] init]; NSMutableArray *secondArray = [[NSMutableArray alloc] init]; NSMutableDictionary *a = [[NSDictionary alloc] init]; [a setObject:@"foo" forKey:"name"]; [a setObject:[NSNumber numberWithInt:1] forKey:"number"];

How to get object for key from NSDictionary?

Deadly 提交于 2019-12-12 08:28:43
问题 In dictionary named dict the key value pair is: "alba\U2019s window" = "A model in westindies."; And to send objectForKey: I am getting the string like "alba's window". When I send like following: [dict objectForKey:alba's window]; I am not getting anything, it is showing null. 回答1: For starters, you might want to make that an actual string, like so: [dict objectForKey:@"alba's window"]; Note also that \U2019 is not ' ; but ’ , which is a different character entirely. And more generally,

_NSArrayM isEqualToString:]: unrecognized selector sent to instance 0x8d70f00

六眼飞鱼酱① 提交于 2019-12-12 06:48:37
问题 i have NSDictionary with with key and its value and i want it to populate into the tableview but i get some error like this: -[__NSArrayM isEqualToString:]: unrecognized selector sent to instance 0x8f8e4d0 2014-08-13 13:29:45.357 SotaApp[1602:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM isEqualToString:]: unrecognized selector sent to instance 0x8f8e4d0' what i have tried is: NSString *value = [filteredDictionaryValues valueForKey:

Display a limited number of sorted annotations in Mapview

孤街浪徒 提交于 2019-12-12 06:12:41
问题 I have an NSArray of 500 annotations and I basically want to show only the ten nearest annotations to the user (the rest would not be added on Mapview) How should I do that? Here is my code: -(void) loadAndSortPOIs { [poiArray release]; nextPoiIndex = 0; NSString *poiPath = [[NSBundle mainBundle] pathForResource:@"annotations" ofType:@"plist"]; poiArray = [[NSMutableArray alloc] initWithContentsOfFile:poiPath]; CLLocation *homeLocation = [[CLLocation alloc] initWithLatitude:homeCoordinate

Persisting a datasource between multiple views without shared root view controller

一曲冷凌霜 提交于 2019-12-12 05:39:51
问题 I'm currently working on an app that uses a UINavigationController inside UITabBars . The tab bars correspond to both UITableViews as well as a Map View. However, the root view controller of the app is not the parent, or direct parent, of the UITableView custom controllers and map view controller. I also have a p-list that creates NSDictionary objects; it is the datasource that I am using to populate entries in the tables and the map. So, without a root view controller, how should I create

Write and read file with list NSDictonary swift

吃可爱长大的小学妹 提交于 2019-12-12 05:14:12
问题 I have a list of NSDictionary, and i want to save it in a file. I can save it in text file but i can't read it to [NSDictionary] var text : [NSDictionary] = [] save file let json = JSONSerializer.toJson(text) try json.write(to: path, atomically: false, encoding: String.Encoding.utf8) This is my list NSDictionary [{ change = true; name = data1; },{ change = true; name = data2; }] 回答1: do { let text2 = try NSString(contentsOfURL: path, encoding: NSUTF8StringEncoding) // path give your file path

iOS NSDictionary pass through function

烈酒焚心 提交于 2019-12-12 04:58:36
问题 I have my view controller named SecondViewController and when user selects which article wants to read, I want to navigate to ThirdViewController and pass NSDictionary with article data. - (void) touchButtonBlock:(NSInteger) select { NSLog(@"touchButtonBlock"); NSDictionary *dict; switch (select) { case 0: { NSMutableDictionary *tmpDict = [[NSMutableDictionary alloc] init]; NSMutableDictionary *val = [[NSMutableDictionary alloc] init]; [val setObject:@"article360.html" forKey:@"page"]; [val

Get sectionIndex titles based on contact name

核能气质少年 提交于 2019-12-12 04:58:18
问题 In my app I have a db with 50k+ contacts. To display them on list view, I need to calculate the index section titles to display them on the right side. However my logic is taking time around 3-6 seconds to prepare the datasource. -(NSArray *)getSectionTitleBasedOn:(NSString*)sortBy{ for (RealmContact *contact in contactSource){ if (contact.firstName.length>0) { if ([sortBy isEqualToString:@"FirstName"]) { NSString *firName= [contact.firstName stringByReplacingOccurrencesOfString:@" "

Adding dictionaries to Plist programmatically

▼魔方 西西 提交于 2019-12-12 04:53:57
问题 I am trying to add a dictionary to a plist programmatically in the following format: Root(Dict) | StringOfViewID(Dict) | ButtonTitle(Dict) | String String I can successfully do this but I want to keep adding to the ViewID(Dict) more ButtonTitle(Dict) under the same ViewID(Dict). So far I can only replace the existing. Something like this: Root(Dict) | StringOfViewID(Dict) - ButtonTitle(Dict)(2)-String String | ButtonTitle(Dict)(1) | String String Here is the code I'm using: //Initialize and