nsdictionary

How do I make my AFNetworking “responseObject” that I receive a NSDictionary I can parse?

不羁的心 提交于 2019-12-22 09:28:24
问题 I have this call with AFNetworking 1.0 that returns a responseObject with the data from the API that I want: [[AFDiffbotClient sharedClient] postPath:@"http://diffbot.com/api/batch" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { However, I have no idea how to process responseObject . If I check [responseObject class] I get NSData . If I NSLog(@"%@", responseObject) I get a bunch of numbers (memory addresses I assume): <5b0a7b22 68656164 65727322

Collection was mutated while being enumerated, UITableView

◇◆丶佛笑我妖孽 提交于 2019-12-22 04:55:29
问题 I have a filter button that presents a UITableView in a popover. I have my categories and an "All" button to denote that no filter is present like in iTunes. I have a NSMutableDisctionary in my applicationDelegate class that I use to set the checkmarks. When the app starts, only All is selected, everything else is deselected. What I want is then when a row that is not "All" is selected, that row gets selected, and All gets deselected. Similarly, when All is selected, all the rows with

Byte size of an NSDictionary

偶尔善良 提交于 2019-12-22 03:57:01
问题 This may sound like a completely stupid question, but how can I get the size in bytes of an NSDictionary? Can I convert it to NSData, and then get the length of that? Help! 回答1: You should say more about why you care about the size of the dictionary in bytes, because the answer might be different depending. In general, the "size" of an NSDictionary's footprint in memory is not something you can see or care about. It abstracts its storage mechanism from the programmer, and uses some form of

NSDictionary Predicate filter on child objects

徘徊边缘 提交于 2019-12-22 00:32:44
问题 I'm trying to filter a response from Facebook's API, the JSON looks like this: { "Data": [ { "first_name" : "Joe", "last_name" : "bloggs", "uuid" : "123" }, { "first_name" : "johnny", "last_name" : "appleseed", "uuid" : "321" } ] } I load this into a NSDictionary, accessing it like [[friendDictionary objectForKey:@"data"] allObjects] I'm now trying to filter based on the first_name and last_name based on when someone inputs a name into a textfield. Here's what I have but its failing horribly:

How to get a value from a JSON Object using NSJSONSerialization

别说谁变了你拦得住时间么 提交于 2019-12-21 19:31:23
问题 I can retrieve the JSON object and display it, but how do I get the value from "lat" and "lng" to use in Xcode? My Code: NSString *str=[NSString stringWithFormat:@"https://www.<WEBSITE>]; NSURL *url=[NSURL URLWithString:str]; NSData *data=[NSData dataWithContentsOfURL:url]; NSError *error=nil; NSDictionary* dictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error]; NSLog(@"Your JSON Object: %@ Or Error is: %@", dictionary, error); JSON Object: ( { response =

Change objects in NSUserDefaults without creating and re-setting copies

故事扮演 提交于 2019-12-21 13:43:14
问题 I've got dictionary stored in NSUserDefaults and I need to add/remove items in this dictionary. It bothers me that to do this I have to create mutable copy of entire dictionary, change one element and replace entire dictionary with new copy. copy = [[defaults objectForKey:@"foo"] mutableCopy]; [copy setObject:… forKey:@"bar"]; [defaults setObject:copy forKey:@"foo"]; and it involves even more copying and re-setting for objects deeper in the hierarchy. Is there a better way? I've tried to use

Objective C - Change all attributes in NSAttributedString?

依然范特西╮ 提交于 2019-12-21 09:55:51
问题 [attributedString enumerateAttributesInRange:range options:NSAttributedStringEnumerationReverse usingBlock: ^(NSDictionary *attributes, NSRange range, BOOL *stop) { NSMutableDictionary *mutableAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes]; [mutableAttributes setObject:[NSNumber numberWithInt:1] forKey:@"NSUnderline"]; attributes = mutableAttributes; }]; I am trying to loop through all attributed and add NSUnderline to them. when debugging it seems like NSUnderline is

How to get values from NSDictionaries inside an NSArray

▼魔方 西西 提交于 2019-12-21 07:28:09
问题 I'd like to know if it's possible to get a values from a desired key inside an NSDictionary that is in NSArray . Example: NSArray *array = @[ @{@"title" : @"title 1", @"description" : @"description 1"}, @{@"title" : @"title 2", @"description" : @"description 2"}, @{@"title" : @"title 3", @"description" : @"description 3"} ]; I'd like to get (without creating a new NSMutableArray ) all the titles inside my NSArray . Maybe I'm doing something wrong and my approach is bad altogether. I know I

NSDictionary With Integer Values

我只是一个虾纸丫 提交于 2019-12-21 06:57:41
问题 I'm working on a game with monsters. Each one has a list of stats that are all going to be ints. I can set up each stat as it's own variable but I'd prefer to keep them in an NSDictionary since they are all related. I'm running into a problem when I'm trying to change the value's of each stat. What I Have: -(id) init { self = [super init]; if(self) { stats = [NSDictionary dictionaryWithObjectsAndKeys: @"Attack", 0, @"Defense", 0, @"Special Attack", 0, @"Special Defense", 0, @"HP", 0, nil]; }

Grab all values in NSDictionary inside an NSArray

会有一股神秘感。 提交于 2019-12-21 05:10:32
问题 I have an NSArray full of NSDictionary objects, and each NSDictionary has a unique ID inside. I want to do lookups of particular dictionaries based on the ID, and get all the information for that dictionary in my own dictionary. myArray contains: [index 0] myDictionary object name = apple, weight = 1 pound, number = 294, [index 1] myDictionary object name = pear, weight = .5 pound, number = 149, [index 3] myDictionary object (etc...) I want to get the name and weight for the second dictionary