nsdictionary

iOS对字典里某一个key的value 进行操作

谁说胖子不能爱 提交于 2019-12-20 04:03:33
iOS对字典中相应的value进行操作 无论是数组里面的字典 还是 字典里面的字典 +(NSDictionary *)nullDic:(NSDictionary *)myDic { NSArray *keyArr = [myDic allKeys]; NSMutableDictionary *resDic = [[NSMutableDictionary alloc]init]; for (int i = 0; i < keyArr.count; i ++) { id obj = [myDic objectForKey:keyArr[i]]; obj = [self changeType:obj]; //在这里加入判断 你想要修改的key 然后value 进行修改 if ([keyArr[i] isEqualToString:@"StartTime"]) { if ([obj isKindOfClass:[NSString class]]) { obj = [(NSString *)obj stringByReplacingOccurrencesOfString:@"T" withString:@" "]; } } else if ([keyArr[i] isEqualToString:@"EndTime"]) { if ([obj isKindOfClass:[NSString

Sorting negative and positive numbers in objective c

泪湿孤枕 提交于 2019-12-20 02:43:27
问题 I am listing out a quantity percentage like stuff for an item via a webservice.The response that I get is an array of dictionaries similar to the below code.I need it in a sorted format 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],@

NSDictionary split into two arrays (objects and keys) and then sorted both by the objects array (or a similar solution)

懵懂的女人 提交于 2019-12-20 02:27:17
问题 I have an NSDictionary. It has keys and objects. For the purposes of simplicity the keys are Question numbers and the objects are calculated Answer scores. Now how I did it before was that I set the answer score as the keys and the question numbers as the objects. This way I could get an array of allKeys from the dictionary, sort it and then do something similar to: for(NSString *string in tempArray){ NSLog(@"%@",[dictionary objectForKey:string]); } The (stupid - on my part) problem that I

Updating & changing settings plist files with new versions of an app

旧巷老猫 提交于 2019-12-20 02:13:44
问题 I've got a default settings plist file in the resources folder of my app, and on the first launch that gets copied to the documents folder. In successive versions of the app, how can I merge the plist settings in their documents with any new keys & values (possibly nested) that have been added since the previous version? I've seen a pattern where properties are actually created as an NSDictionary in the app (with all default settings), and then the current settings saved in the plist file is

Creating a constant dictionary object

若如初见. 提交于 2019-12-19 17:38:08
问题 I would like to accomplish something like what is being done in this post: Constants in Objective-C however, i would like to construct an NSDictionary. if i do something like: constants.h extern NSArray *const mFooKeys; extern NSArray *const mFooObjects; extern NSDictionary *const mFooDictionary; constants.m NSArray *const mFooKeys = [[NSArray alloc] initWithObjects: @"Foo", @"Bar", @"Baz", nil]; NSArray *const mFooObjects = [[NSArray alloc] initWithObjects: @"1", @"2", @"3", nil];

Get data from a PList into UITableView?

不羁岁月 提交于 2019-12-19 10:13:14
问题 I want to maintain a list of records, for each one I maintain the same type of data. I want to use this data in 2 different places: UITableView that takes from each record the "Name" value UIViewController that takes all the data to use in different fields. I assume I should be using a plist to store the data; I also assume that the object that should be receiving the data for the UITableView is NSArray so I can use the cellForRowAtIndexPath method to create the table automatically. So i

iOS Using NSDictionary to load data into section and rows

[亡魂溺海] 提交于 2019-12-19 04:42:36
问题 I wish to display table section with date as the section title and name of book in the row. I'm all lost at how to use a NSDictionary to load data into section and rows. Therefore my codes are all screwed up :( Can anyone offer some help, with some sample codes as a guide? My NSMutableArray is as followed: ( { BIBNo = 187882; date = "14/08/2012"; itemSequence = 000010; name = "Increasing confidence / Philippa Davies."; noOfRenewal = 0; number = 000187907; status = "Normal Loan"; time = "24:00

Sort array into dictionary

徘徊边缘 提交于 2019-12-19 02:02:53
问题 I have and array of many strings. I wan't to sort them into a dictionary, so all strings starting the same letter go into one array and then the array becomes the value for a key; the key would be the letter with which all the words in it's value's array begin. Example Key = "A" >> Value = "array = apple, animal, alphabet, abc ..." Key = "B" >> Value = "array = bat, ball, banana ..." How can I do that? Thanks a lot in advance! 回答1: NSArray *list = [NSArray arrayWithObjects:@"apple, animal,

Remove objects using NSPredicate

こ雲淡風輕ζ 提交于 2019-12-18 18:30:55
问题 I have the folloving dictionary which has many sub dictionaries. How can I remove objects where isChanged = 1 from parent dictionary using NSPredicate ? { "0_496447097042228" = { cellHeight = 437; isChanged = 1; }; "100000019882803_193629104095337" = { cellHeight = 145; isChanged = 0; }; "100002140902243_561833243831980" = { cellHeight = 114; isChanged = 1; }; "100004324964792_129813607172804" = { cellHeight = 112; isChanged = 0; }; "100004324964792_129818217172343" = { cellHeight = 127;

Updating UIImage orientation metaData?

杀马特。学长 韩版系。学妹 提交于 2019-12-18 11:55:16
问题 Basic Task: update the EXIF orientation property for the metaData asociated with a UIImage. My problem is that I don't know where the orientation property is in all the EXIF info. Convoluted Background: I am changing the orientation of the image returned by imagePickerController:didFinishPickingMediaWithInfo: so I am thinking that I also need to update the metaData before saving the image with writeImageToSavedPhotosAlbum:(CGImageRef)imageRef metadata:(NSDictionary *)metadata . In other words