nsdictionary

Filtration by Comparison of Dictionary Objects in NSArray

痴心易碎 提交于 2019-12-11 08:23:52
问题 I have an array of dictionaries that I need to filter in a very specific way. It's easiest to explain by example. Let's say I have an array containing the following three dictionaries where @"threadId", @"subject", @"messageId" are keys: NSDictionary #1: @"threadId" : @"1234" @"subject" : @"hello" @"messageId" : @"0001" NSDictionary #2: @"threadId" : @"1234" @"subject" : @"hello" @"messageId" : @"0002" NSDictionary #3: @"threadId" : @"9101" @"subject" : @"goodbye" @"messageId" : @"0005" I'm

Initialize NSArray with data from NSdictionary

人盡茶涼 提交于 2019-12-11 07:44:32
问题 I receiving data from URL, put it in NSDictionary, and then I need to create NSArray for each tags. My NSDictionary looks like: ( { id = { text = 1; }; logo = { text = "url 1"; }; name = { text = "some name 1"; }; }, { id = { text = 2; }; logo = { text = "url 2"; }; name = { text = "some name 2"; }; }, { id = { text = 3; }; logo = { text = "url 3"; }; name = { text = "some name 3"; }; } ) I want to have array like that: arrLogo = (@"url 1", @"url 2", "url 3"). I'm doing next: arrName=[[dict

Loading plist into iOS TableView

Deadly 提交于 2019-12-11 07:37:00
问题 I have a plist ( images.plist ) with the following contents As you can see, each item has a numerical key, from 0-19. Each item also has two strings (fileName and fileInfo). I'm trying to load all of the fileName's into a TableView. Here's my attempt: RosterMasterViewController.h @interface RosterMasterViewController : UITableViewController @property (nonatomic, strong) NSDictionary *roster; @end RosterMasterViewController.m @implementation RosterMasterViewController @synthesize roster =

Accessing Nested NSDictionary values in Swift 3.0

你说的曾经没有我的故事 提交于 2019-12-11 07:32:49
问题 I have the following data I received from Firebase. I have made my snapshotValue a NSDictionary. self.ref.child("users").child(facebookID_Firebase as! String).observeSingleEvent(of: .value, with: { (snapshot) in let snapshotValue = snapshot.value as? NSDictionary print(snapshotValue, "snapshotValue") //this line of code doesn't work //self.pictureURL = snapshot["picture"]["data"]["url"] }) { (error) in print(error.localizedDescription) } I tried How do I manipulate nested dictionaries in

NSDictionary / Base64 String Logs

心不动则不痛 提交于 2019-12-11 06:46:15
问题 I have this weird problem about NSDictionary and base64 String and I cannot locate where the problem is. Here's the code: NSData *pictureData = [[NSData alloc]init]; pictureData = UIImagePNGRepresentation([UIImage imageNamed:@"logo"]); NSString * picture = [pictureData base64EncodedString]; picture = [picture stringByReplacingOccurrencesOfString:@"+" withString:@"%2B"]; if(picture == nil){ picture = @""; } self.postDictionary = [[NSDictionary alloc]initWithObjectsAndKeys:picture,@"picture",@

how to parse json data from local files?

情到浓时终转凉″ 提交于 2019-12-11 06:35:10
问题 i am very new to json parsing and tried to parse a json file which has list of cars but when i do parse, it gives out nil func jsonTwo(){ let url = Bundle.main.url(forResource: "car_list", withExtension: "json")! let data = try! Data(contentsOf: url) let JSON = try! JSONSerialization.jsonObject(with: data, options: []) as? [String : Any] print(".........." , JSON , ".......") let brand = JSON?["models"] as? [[String : Any]] print("=======",brand,"=======") } and when i made some modifications

Copying an NSDictionary without empty values?

雨燕双飞 提交于 2019-12-11 06:31:33
问题 I'm trying to create an NSDictionary with the dictionaryWithDictionary method. However, my first NSDictionary A may have some keys with empty values. How can I create B that doesn't have any keys with empty values? I'm doing all of this for the purposes of populating a UITableView with rows that correspond to each non-empty key in the NSDictionary . 回答1: How about something like this: NSMutableDictionary *destDictionary = [NSMutableDictionary dictionaryWithCapacity:[sourceDictionary count]];

“Unable to restore previously selected frame” when looping through NSDictionary

自作多情 提交于 2019-12-11 06:25:05
问题 I got the following errors in my app: warning:Unable to restore previously selected frame warning:Unable to restore previously selected frame when using the following code: NSDictionary *feed = [json_parser objectWithString:json_str error:nil]; for(NSDictionary *feed_item in [feed objectForKey:@"items"]) { PropertyData *propertyData; // mere data model class with properties only,no methods [propertyData release]; } with this line hightlighted Thread 1: Program received signal: "EXC_BAD_ACCESS

Objective C: I'm trying to save an NSDictionary that contains primitives and object, but error occurred once i tried adding the custom object

假装没事ソ 提交于 2019-12-11 05:49:45
问题 So I have this custom object i made called 'Box', it's throwing the error for that one. Inside of my NSDictionary is... box = [[Box alloc] initWithHeight:20 height:40]; wrap.dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:numberInt, kInt, numberShort, kShort, numberLong, kLong, numberFloat, kFloat, numberDouble, kDouble, numberBool, kBool, nsString, kString, nsDate, kDate, box, @"keybox", nil]; Notice the box object that I created up top and added in the NSDictionary at the very end.

Saving IOS data to plist

我怕爱的太早我们不能终老 提交于 2019-12-11 05:17:11
问题 I am writing these data to plist file, but every time I write, it replaces whatever was there before. I.e it is overwriting whatever data I had previously when I reload the page. How can I make the previous data persist or could someone point out what I am not doing correctly? - (IBAction)buttonClickSave:(id)sender; { pathList=[self getFilePath]; if(![[NSFileManager defaultManager] fileExistsAtPath:pathList]) { [[NSFileManager defaultManager] copyItemAtPath:[[NSBundle mainBundle]