Tag: nsdictionary

JSONkitsorting问题

我正在使用基于REST的Web服务来获取数据。 不pipeJSON文档的结构如何,NSDictionary都以相同的方式填充。 我想在Web服务返回时保留sorting。 这是我的代码: -(void) getData { NSURL *url = [NSURL URLWithString:@"http://somewebservice"]; __block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setCompletionBlock:^{ // Use when fetching text data NSString *responseString = [request responseString]; NSDictionary *resultsDictionary = [responseString objectFromJSONString]; [jokesArray release]; jokesArray = [resultsDictionary allValues]; //always has the same order. [jokesArray retain]; [self.tableView reloadData]; // Use when fetching […]

如何将NSMutableDictionary保存到文档中的文件?

我想将一个NSMutableDictionary对象的内容保存到一个文件。 我该怎么做呢 ? 我已经知道如何做一个NSDictionary对象这个任务,但我不知道如何将此NSMutableDictionary转换/复制到一个NSDictionary …除非有一种方法直接写入NSMutableDictionary的内容到一个文件…我强调NSMutableDictionary对象包含NSDictionarytypes的对象。 Thx帮助, 斯特凡

从NSDictionary获取值

嗨,我是新的iOS开发。 我想获得回应,并将这些值添加到variables。 我尝试过,但我得到的答复。 我不明白为什么会有这样的反应。 @"[{\"VisitorID\":\"2864983a-e26b-441a-aedf-84e2a1770b8e\",\"ProfileID\":\"69c02265-abca-4716-8a2f-ac5d642f876a\",\"CompanyID\":null,\"VisitorName\":\"kanasalingam\",\"OperatorName\":\"baman\",\"Image\":null,\"isocode\":\"lk\",\"CurrentOperator\":[\"69c02265-abca-4716-8a2f-ac5d642f876a\"]},{\"VisitorID\":\"133bc108-b3bf-468a-9397-e1b0dba449db\",\"ProfileID\":\"69c02265-abca-4716-8a2f-ac5d642f876a\",\"CompanyID\":null,\"VisitorName\":\"kumar\",\"OperatorName\":\"baman\",\"Image\":null,\"isocode\":\"lk\",\"CurrentOperator\":[\"69c02265-abca-4716-8a2f-ac5d642f876a\"]}]" 我试过这个: – (void) sendOtherActiveChats:(NSDictionary *) chatDetails{ NSLog(@"inside sendOtherActiveChats"); NSLog(@"otherDetails Dictionary : %@ ", chatDetails); NSString *VisitorID = [chatDetails objectForKey:@"VisitorID"]; NSString *ProfileID = [chatDetails objectForKey:@"ProfileID"]; NSString *CompanyID = [chatDetails objectForKey:@"CompanyID"]; NSString *VisitorName = [chatDetails objectForKey:@"VisitorName"]; NSString *OperatorName = [chatDetails objectForKey:@"OperatorName"]; NSString *isocode = [chatDetails objectForKey:@"isocode"]; NSLog(@"————————Other Active Chats ———————————–"); NSLog(@"VisitorID : […]

iOS – 区分NSDictionary和NSMutableDictionary?

我有以下代码片段: NSString* value = @"value"; NSString* key = @"key"; NSMutableDictionary* foo = [NSMutableDictionary dictionary]; NSDictionary* bar = [NSDictionary dictionary]; NSAssert([bar isKindOfClass: [NSMutableDictionary class]], @""); // passes the assert as both are NSCFDictionary; NSAssert([bar respondsToSelector: @selector(setValue:forKey:)], @""); // passes the assert because it NSCFDictionary does respond to the selector [foo setValue:value forKey:key]; // no problem, foo […]

在目标c中对负数和正数进行sorting

我通过webservice列出了一个数量百分比像一个项目的东西。我得到的响应是一个类似于下面的代码的字典数组。我需要一个有序的格式 NSArray *numberArray = [NSArray arrayWithObjects: [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:-12.0], @"price", nil], [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:-86.0],@"price", nil], [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:-8.0],@"price", nil], [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:12.0],@"price", nil], [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:2.0],@"price", nil], [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:112.0],@"price", nil], nil]; 这是JSON响应的日志 [ { price = "-12"; }, { price = "-86"; }, { price = "-8"; }, { price = 12; }, { […]

:无法识别的select器发送到实例

我正在试图添加“date时间”我的字典定义如下: Symptom Ranking: { 5111ef19253b4a9150000000 = 1; 5111f029253b4add4e000000 = 1; 5111f036253b4a123d000001 = 1; 5111f045253b4a404f000000 = 1; } NSLog(@"date selected: %@", [[self.datePicker date] description]) [self.results setObject:[[self.datePicker date] description] forKey:@"dateTime"]; 应用程序崩溃,我得到这个: Symptom Tracker[43134:c07] -[__NSDictionaryI setObject:forKey:]: unrecognized selector sent to instance 0x7603990 2013-02-06 08:15:58.741 Symptom Tracker[43134:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI setObject:forKey:]: unrecognized […]

将NSDictionary键sorting为NSDate

我正在开发一个最新的SDK和XCode 4.2的iOS 4应用程序。 我有一个NSMutableDictionary其中键是NSDate和值是NSMutableString 。 当我填补了NSMutableDictionary我想sorting它的键,但我不知道我该怎么做。 我想要一月份的第一个date,然后是二月份,等等。 NSDate密钥格式是dd / mm / yyyy 。 当NSMutableDictionary具有所有的键和值时,如何sorting这些键? (我不会添加更多)。

iOS使用NSDictionary将数据加载到段和行中

我希望显示表格部分的date作为部分标题和行中的书名。 我都迷失在如何使用NSDictionary将数据加载到部分和行。 因此,我的代码都搞砸了:(任何人都可以提供一些帮助,一些示例代码作为指导?我的NSMutableArray如下: ( { BIBNo = 187882; date = "14/08/2012"; itemSequence = 000010; name = "Increasing confidence / Philippa Davies."; noOfRenewal = 0; number = 000187907; status = "Normal Loan"; time = "24:00"; type = Loans; }, { BIBNo = 291054; date = "14/08/2012"; itemSequence = 000010; name = "iPhone application development for IOS […]

如何使用PFQuery作为NSDictionary的值存储的PFObject数组

我在iOS应用程序中使用parse.com将数据存储到parsing云服务。 我遇到了嵌套对象查询的麻烦。 我有以下数据模型: “游戏”类包含“赢家” “winners”是一个NSDictionary的数组, NSDictionary中的每一项都是一个Player到N Powers的映射 playerPowers的值是PFObject的一个数组(PFObject) (当前只有一个名字),用于key:objectId (PFObject) 对于每个获胜者,我添加到“赢家”(可以有多个获奖者)一个NSDictionary对象,如下所示: NSDictionary * winnerWithPowers = [NSDictionary dictionaryWithObject:tempPowers forKey:[aWinnerPFObject objectId]]; [newGame addObject:winnerWithPowers forKey:@"winners"]; 对于字典中的每个项目,密钥是玩家的现有对象PFObjects ,值也是服务器上的PFObjects (权力)数组。 当我查询“优胜者”时,我想检索所有数据填充,所有获奖者和他们各自的权力PFObjects与他们的所有数据。 当我查询“赢家”每个functionPFObject的细节是不完整的(key:name的值为null)。 以下是查询,然后是打印结果的代码,然后输出包含两个赢家的字典: //在viewWillAppear: PFQuery * gamesQuery = [PFQuery queryWithClassName:@"Game"]; [gamesQuery orderByDescending:@"createdAt"]; [gamesQuery findObjectsInBackgroundWithBlock:^(NSArray * theGames, NSError * error) { if (error) { NSLog(@"ERROR: There was an error with the […]

insertObject:atIndex: – 索引3超出空数组的边界

我创build一个基于字典键的数组: factsBuiltArray = [NSMutableArray arrayWithCapacity: 6]; if ([statusDict count] == 10) { for (NSString *key in [statusDict allKeys]) { if ([key isEqualToString: @"currenciesAndConversions"]) { [factsBuiltArray insertObject:key atIndex: 0]; } else if ([key isEqualToString: @"languageAndTranslations"]) { [factsBuiltArray insertObject:key atIndex: 1]; } else if ([key isEqualToString: @"plugSize"]) { [factsBuiltArray insertObject:key atIndex: 2]; } else if ([key isEqualToString: […]