nsdictionary

Loop through NSDictionary to create separate NSArrays

人盡茶涼 提交于 2019-12-03 12:06:02
问题 I have a large NSDictionary that I need to loop through and create separate NSArray s. Here are the contents: ( { id = { text = ""; }; sub = { text = " , "; }; text = ""; "thumb_url" = { text = ""; }; title = { text = "2010-2011"; }; type = { text = "title"; }; }, { id = { text = "76773"; }; sub = { text = "December 13, 2010"; }; text = ""; "thumb_url" = { text = "http://www.puc.edu/__data/assets/image/0004/76774/varieties/thumb.jpg"; }; title = { text = "College Days - Fall 2010"; }; type =

Convert nsdictionary to nsdata

若如初见. 提交于 2019-12-03 12:03:50
问题 have an app that can take a picture and then upload to a server. encoding it to base 64 and pass it thru a XMLRPC to my php server. i want to take the NSDictionary info that is returned from UIImagePickerController delegate -(void) imagePickerController:(UIImagePickerController *)imagePicker didFinishPickingMediaWithInfo:(NSDictionary *)info and convert it to NSData so i can encode it. so, how can i convert NSDictionary to an NSData? 回答1: You can use an NSKeyedArchiver to serialize your

Cocoa's NSDictionary: why are keys copied?

随声附和 提交于 2019-12-03 11:02:11
问题 All objects used as keys in NS(Mutable)Dictionaries must support the NSCopying protocol, and those objects are copied when they're used in the dictionary. I frequently want to use heavier weight objects as keys, simply to map one object to another. What I really mean when I do that is effectively: [dictionary setObject:someObject forKey:[NSValue valueWithPointer:keyObject]]; ("When I come back and hand you this same key object instance again, get me that same value out.") ...which is exactly

Why doesn’t [NSDictionary allKeys] return a set?

限于喜欢 提交于 2019-12-03 10:52:16
Is there a reason for NSDictionary to return its keys as NSArray instead of NSSet ? The documentation already states that the order of the keys in the array is undefined, it would sound logical to use a set. Sets tend to be somewhat neglected in API design. They'll be included most of the time, but usually long after all the other standard data structures. Add on top of that the fact that besides the very recent NSFastEnumeration, there is no general collection or sequence protocol in Objective-C — every collection class is completely independent of all the others — and it becomes very hard to

Unable to use 'class' as a key in NSDictionary

大憨熊 提交于 2019-12-03 10:51:38
I'm trying to use a class as a key in an NSDictionary . I looked at the answer to this question and what I have is pretty much the same; I'm using setObject: forKey: . However, XCode complains, saying Incompatible pointer types sending 'Class' to parameter of type 'id<NSCopying>' . The call I have is: [_bugTypeToSerializerDictionary setObject: bugToStringSerializer forKey: [bugToStringSerializer serializedObjectType]]; bugToStringSerializer is an instance of BugToStringSerializer whose concrete implementations implement serializedObjectType . An example of a concrete implementation looks like

Check if NSDictionary is empty

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 10:40:57
I want to check if an NSDictionary is empty. I am doing it like this. mutDictValues = [[[NSUserDefaults standardUserDefaults] objectForKey:@"dicValues"]mutableCopy]; NSLog(@"dictValues are %@",mutDictValues); if(mutDictValues == NULL){ arrCities = [[NSMutableArray alloc]init]; NSLog(@"no cities seleceted"); }else{ arrCities = [[NSMutableArray alloc]init]; arrCities = [mutDictValues objectForKey:@"cities"]; [self placeCities]; } But it alwasy crashes on this line arrCities = [mutDictValues objectForKey:@"cities"]; with the following error: -[__NSCFConstantString objectForKey:]: Can someone help

UIView as dictionary key?

旧街凉风 提交于 2019-12-03 09:29:50
I want to have a NSDictionary that maps from UIView s to something else. However, since UIViews do not implement the NSCopying protocol, I can't use them directly as dictionary keys. You can use an NSValue holding the pointer to the UIView and use this as key. NSValues are copyable. but, if the view is destroyed, the NSValue will hold a junk pointer. Rok Strniša Here is the actual code (based on the answer by luvieere and further suggestion by Yar): // create dictionary NSMutableDictionary* dict = [NSMutableDictionary new]; // set value UIView* view = [UILabel new]; dict[[NSValue

Populate tableview from NSDictionary

孤者浪人 提交于 2019-12-03 09:00:58
I have an NSDictionary received from a json request that looks like this: RESULT : ( { Id1 = 138; lat = "45.5292910"; long = "-73.6241500"; order = "2343YY3" }, { Id1 = 137; lat = "45.5292910"; long = "-73.6241500"; order = "2343YY3" }, etc. I want to display it in a TableView (CellforRowAtIndexPath), so I obtain the data as NSArray. The method seems inefficient as each key Id1 , lat , long , etc is created as an NSArray so that I can display them each with: [self.data1 objectAtIndex:indexPath.row]; [self.data2 objectAtIndex:indexPath.row] , etc. How can I achieve the same thing without

Convert a JSON NSData to NSDictionary

匿名 (未验证) 提交于 2019-12-03 08:41:19
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using an API service of a web service and it is written in their description that they send JSON data wich also matches in my opinion with the response I get from it. Here a part of it which I got from the NSURLConnection-Delegate (connection didReceiveData: (NSData *) data) and converted in a NSString using: NSLog(@"response: %@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); Here the snippet: {"scans": { "Engine1“: { "detected": false, "version": "1.3.0.4959", "result": null, "update": "20140521" }, "Engine2“: {

IOSLinkedInAPI: Can&#039;t share post with the LinkedIn API

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have been using following SDK to perform integration of LinkedIn into iOS and sharing post from iDevices. SDK is available here: https://github.com/jeyben/IOSLinkedInAPI In this code I can't find proper example code but however I had written some code through which post can be shared. Here is my code: In the code I have only single viewcontroller in which I have taken only two buttons, 1) Linked In Account [This button is used to present login controller and gets user successfully logged into the account] 2) Share [Allows user to share