nsdictionary

how to group array of nsdictionary according to the value inside the element

主宰稳场 提交于 2019-12-13 08:55:42
问题 I have array of dictionary that needs to be grouped according to PO which is part of the element and also get the total of quantityOrdered according to the same PO. The PO is dynamic it means it can be any value that needs to be filtered and compute the quantityOrderd accordingly. Please help. { PO = PO2; QuantityReceived = 1; }, { PO = PO1; QuantityReceived = 3; }, { PO = PO1; QuantityReceived = 3; }, { PO = PO3; QuantityReceived = 2; }, { PO = PO2; QuantityReceived = 2; }, { PO = PO3;

Not able to write NSDictionary to plist file

雨燕双飞 提交于 2019-12-13 07:35:44
问题 Update: I am able to write tot he file when I change the following line [infoDict setObject:userList forKey:@"users"]; to [infoDict setObject:@"sampleString" forKey:@"users"]; so, there must be problem with the structure I'm trying to write to the file, any thoughts? I am trying to create a plist file and write to it at runtime in my iOS app. I am not able to write to it but I'm able to read though. The writeToFile method returns a 'NO'. When I manually try to manually open the file I created

parsing complex XML structure using NSXMLParser

只谈情不闲聊 提交于 2019-12-13 07:24:22
问题 I have this fairly complex XML being returned from my server, I would like some help parsing it into a object I can acess for later use. This is what the xml looks like <Eng> <Result > <Series > <Link/> <FMF/> <AlsoLink/> <Plugins/> </FMF> <Sheet > <Spaces> <Spacing > <Names/> </Spacing> <Spacing > <Names/> </Spacing> </Spaces> </Sheet> </Series> </Result> </Eng> I am then using NSXMLParser to try and parse all of the "ObjectForKey/s" of each element in the xml into their own dictionarys.. if

How to send an NSDictionary (or plist file) as NSData using GameKit bluetooth?

久未见 提交于 2019-12-13 06:48:52
问题 I'm trying to use [currentSession sendDataToAllPeers:data withDataMode:GKSendDataReliable error:nil]; to send an NSDictionary (or a plist file) containing data from 1 device to another, and - (void)receiveData:(NSData *)data fromPeer:(NSString *)peer inSession:(GKSession *)session context:(void *)context to receive it. How can I convert to and from NSData for this to happen? 回答1: You can use the following to transform Plist to NSData: + (NSData *)dataWithPropertyList:(id)plist format:

How to Join two tables data into UITableView using Sqlite iPhone and how to set NSDictionary object?

自作多情 提交于 2019-12-13 06:23:41
问题 How to join my two tables data into another screen in this Am Struck with the NSDictionary,NSArray and NSString how to add object into NSDictionary? Below is my DBClass.m #import "DBClass.h" @implementation DBClass +(NSString *)connectdb { NSArray *docDir=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *dbFolder=[docDir objectAtIndex:0]; NSFileManager *manager=[NSFileManager defaultManager]; if (![manager fileExistsAtPath:dbFolder]) { [manager

reloadData not working for UITableView dataSource?

此生再无相见时 提交于 2019-12-13 06:18:19
问题 Currently I have a NSMutableArray that loads from NSUserDefaults in my app and feeds the data to my UITableView. The NSMutableArray consists of NSDictionarys which consist of 5 or 6 keys each. Then in the view where the UITableView is, I have a UISegmentedControl where the user can then sort the UITableView based upon Date or some other things. So when they click the date segment, I execute this code: NSSortDescriptor *descriptor = [NSSortDescriptor sortDescriptorWithKey:@"Date" ascending:NO]

Sum of records in property list

五迷三道 提交于 2019-12-13 06:01:59
问题 How can I calculate the sum of all numbers in all dictionaries for the key for example "Hours"? Couldn't find any informations about that. Here is piece of my property list I'm talking about: <plist version="1.0"> <array> <dict> <key>Address1</key> <string>17 Stanley Road</string> <key>Address2</key> <string>Essex</string> <key>City</key> <string>Southend On Sea</string> <key>Email</key> <string>lmozdzen@gmail.com</string> <key>Lessons</key> <array> <dict> <key>LessonComment</key> <string><

Swift: Parsing Json string and populating information into a dictionary

ⅰ亾dé卋堺 提交于 2019-12-13 05:43:31
问题 I'm currently learning about web services in Swift. I have this URL that shows recent earthquakes and other information regarding it. The code at the bottom is what I have so far, once I run it, it NSLogs a string in JSON format from the URL. Here are 3 records I have from the string. How do I parse this JSON string and take out the ID, title, and populate that information into a dictionary? html = [ { "response":1, "message":"OK", "count":50 }, { "id":133813, "title":"M 1.4 - 8km NE of

Create plist file via code

好久不见. 提交于 2019-12-13 05:39:15
问题 I want to create a plist file like this: in code, and then it will be in the Caches folder. I already know how to fetch the data. 回答1: You can do it like this: //Create a Mutant Dictionary NSMutableDictionary *theMutantDict = [[NSMutableDictionary alloc] init]; //Fill it with data [theMutantDict setObject:@"John" forKey:@"Name"]; [theMutantDict setObject:@"Doe" forKey:@"Lastname"]; //Then search for cache dir NSString *libraryDir = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,

iOS - Storing groups of UILabels into a NSMutableArray

有些话、适合烂在心里 提交于 2019-12-13 04:26:12
问题 I'm creating UILabel s dynamically in a for each loop. Every loop that is run creates 1-4 UILabels. What I want is that I put these UILabels into my NSMutableArray and being able later to easy retrieve the data. My original thought was to put these UILabels into a NSDictionary and use [dictGroupLabels setValue:uiLabel1 forKey:@"uiLabel1"] and then [dictGroupLabels setValue:uiLabel2 forKey:@"uiLabel2"] and so on. And then put this dictionary into my NSMutableArray for each loop. Later on I