Tag: nsdictionary

如何从NSDictionary中删除空值

我有一个JSON Feed: { "count1" = 2; "count2" = 2; idval = 40; level = "<null>"; "logo_url" = "/assets/logos/default_logo_medium.png"; name = "Golf Club"; "role_in_club" = Admin; } 问题是"<null>" ,我不知道如何将其保存到NSUserDefaults之前从NSDictionary中删除。 请帮我解决这个问题。 谢谢!

在nsdictionary中获取特定键的值

我将jsonparsing结果保存在一个dictionary ,如下所示: { "statusCode":"200", "body":[ { "status":"success", "remarks":null } ], "data":[ "abcd":[ { "category":"a", "title":"b", "id":"24" }, { "category":"c", "title":"crd", "id":"65" }, { "category":"ds", "title":"sd", "id":"18" } ] }, { "efgh":[ { "category":"ds", "title":"sd", "id":"18" }, { "category":"sd", "title":"sd", "id":"1" } ] }, { "ijkl":[ { "category":"ds", "title":"sd", "id":"18" }, { "category":"sd", "title":"sd", "id":"1" } […]

使用NSPredicate过滤NSDictionary对象的NSArray

我有NSArray的NSDictionary对象。 我想使用NSPredicate根据字典的键过滤数组。 我一直在做这样的事情: NSString *predicateString = [NSString stringWithFormat:@"%@ == '%@'", key, value]; NSPredicate *predicate = [NSPredicate predicateWithFormat:predicateString]; NSArray *filteredResults = [allResultsArray filteredArrayUsingPredicate:predicate]; 这个工作正常,如果他们的钥匙传入是单词:颜色,名称,年龄。 但是,如果密钥是多字,则不起作用,如:人员年龄,人员姓名。 基本上,任何包含空格的键都不起作用。 我试图把单引号围绕string中的键,就像他们在价值方面做,但也没有工作。 也试过双引号,但无济于事。 请告知这个。 提前致谢。

将NSDictionary存储在钥匙串中

使用KeychainItemWrapper (或不使用)可以将一个NSDictionary存储在iPhone钥匙KeychainItemWrapper ? 如果这是不可能的,你有另一种解决scheme吗?

如何从谷歌地图的标记在ios中的dictionay?

在我的应用程序中,我已经做了JSONparsing,我得到了一个字典的forms的坐标,我想使用坐标angd在地图上绘制它, 我有使用这个 SBJsonParser *jsonParser = [SBJsonParser new]; NSArray *jsonData = (NSArray *) [jsonParser objectWithString:outputData error:nil]; for(int i=0;i<[jsonData count];i++) { NSDictionary *dict=(NSDictionary *)[jsonData objectAtIndex:i]; Nslog(@"%@",dict); double la=[[dict objectForKey:@"latitude"] doubleValue]; double lo=[[dict objectForKey:@"longitude"] doubleValue]; CLLocation * loca=[[CLLocation alloc]initWithLatitude:la longitude:lo]; CLLocationCoordinate2D coordi=loca.coordinate; marker=[GMSMarker markerWithPosition:coordi]; marker.snippet = @"Hello World"; marker.animated = YES; marker.map = mapView; } 它被打印为 [{"driver_id":"Tn1234sunil@gmail.com","username":"sunil","latitude":"0.000000000000000", "longitude":"0.000000000000000"}, […]

如何重构NSDictionaries的对象

在我的debugging器中,这是我的日志语句如何打印我的消息对象: self.messages = ( "<lean: 0x7fcf98665140, objectId: vglE1UJ5KI, localId: (null)> {\n messageBody = Jj;\n recipientId = XvvxETqjph;\n senderId = XvvxETqjph;\n timestamp = \"1424991590106.210938\";\n}", "<lean: 0x7fcf98667940, objectId: rgBFYBMKlU, localId: (null)> {\n messageBody = \"test 3 from ian\";\n recipientId = XvvxETqjph;\n senderId = Hoy7UjLzOh;\n timestamp = \"1424631667110.638184\";\n}", "<lean: 0x7fcf98667f30, objectId: hB5uhwsYsu, localId: (null)> {\n messageBody = \"test […]

如何使用本地Swift方式来读取Swift 3中的Plist?

我已经在Swift 2中使用了这个方法 var myDict: NSDictionary? if let path = NSBundle.mainBundle().pathForResource("Config", ofType: "plist") { myDict = NSDictionary(contentsOfFile: path) } 但不知道如何在不使用NSDictionary(contentsOfFile:path)的情况下读取Swift3中的plist

NSNumber与NSString映射的NSDictionary是非属性列表对象

以下代码: [[NSUserDefaults standardUserDefaults] setObject:photoIdToPath forKey:@"photo_id_to_path"]; 给我以下错误: Attempt to set a non-property-list object { 417675729 = "/Users/k06a/Library/Application Support/iPhone Simulator/7.1/Applications/21163736-DF6F-4E79-8196-6A966C81ED1B/Documents/417675729"; } as an NSUserDefaults value for key photo_id_to_path 这里是来自Xcodedebugging控制台的photoIdToPath字典内容分析: (lldb) po photoIdToPath { 417675729 = "/Users/k06a/Library/Application Support/iPhone Simulator/7.1/Applications/21163736-DF6F-4E79-8196-6A966C81ED1B/Documents/417675729"; } (lldb) po [[[photoIdToPath allKeys] lastObject] class] __NSCFNumber (lldb) po [[[photoIdToPath allValues] lastObject] class] NSPathStore2 所以NSPathStore2是NSString子类,为什么这个字典不是属性列表? 更新: 这里https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/nsuserdefaults_Class/Reference/Reference.html#//apple_ref/occ/instm/NSUserDefaults/setObject:forKey :我发现文字: […]

根据NSDictionay中的键将NSDictionary的NSArray分组

我正在试图过滤出NSDictionaries的NSArray。 以我的下面的例子,我想dict1,dict2&dict4分组在一个数组中,dict3&dict5分组在第二个数组和dict6在第三个数组。 我在NSArray中获取这个数据,所以基本上下面的“orig”数组是我的input,我知道我需要根据“名称”键进行分组。 而不是通过NSArray循环我虽然使用valueForKeyPath返回我基于关键path的数组,但这不起作用(与日志崩溃 – [NSMutableArray addObjectsFromArray:]:数组参数不是NSArray')。 任何build议。 NSDictionary *dict1 = @{@"Name" : @"T1", @"Age" : @"25"}; NSDictionary *dict2 = @{@"Name" : @"T1", @"Age" : @"25"}; NSDictionary *dict3 = @{@"Name" : @"T2", @"Age" : @"27"}; NSDictionary *dict4 = @{@"Name" : @"T1", @"Age" : @"25"}; NSDictionary *dict5 = @{@"Name" : @"T2", @"Age" : @"27"}; NSDictionary *dict6 […]

NSDictionary allKeys命令

我需要在UITableView中显示API返回的NSDictionary的内容,尊重键的顺序。 我在用着 : – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *key = self.data.allKeys[indexPath.section]; NSArray *list = self.data[key]; id data = list[indexPath.row]; PSSearchCell *cell = [PSSearchCell newCellOrReuse:tableView]; cell.model = data; return cell; } 但正如我做self.data.allKeys ,我失去了我的钥匙的顺序。 我不能按价值分类,因为它们不涉及它们。