nsdictionary

Loop through NSDictionary to create separate NSArrays

a 夏天 提交于 2019-12-03 02:34:49
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 = { text = "gallery"; }; }, { id = { text = ""; }; sub = { text = ""; }; text = ""; "thumb_url" = { text

How do I convert an NSDictionary to a Swift Dictionary<String, NSObject>?

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am rewriting an Objective-C class in Swift to get a feel for the language. In Objective-C my class included the following method: - (id) initWithCoder:(NSCoder *)aDecoder { return [self initWithActionName:[aDecoder decodeObjectOfClass:[NSString class] forKey:@"actionName"] payload:[aDecoder decodeObjectOfClass:[NSDictionary class] forKey:@"payload"] timestamp:[aDecoder decodeObjectOfClass:[NSDate class] forKey:@"timestamp"]]; } After some trial and error with the compiler, I managed to rewrite it like this: convenience init(aDecoder:

FBSDK (New Facebook SDK 4.0) Implementation is not working for Login with Facebook

匿名 (未验证) 提交于 2019-12-03 02:18:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using this following block which is mentioned in Facebook Developer . But when my App callbacks from Browser then it is always returning Cancelled result. FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init]; [login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) { if (error) { // Process error } else if (result.isCancelled) { // Handle cancellations } else { // If you ask for multiple permissions at once, you // should check if specific permissions missing if ([result

NSDictionary to NSArray?

匿名 (未验证) 提交于 2019-12-03 02:14:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i have a NSDictionary which looks like: { "Item1" = 2.4; "Item2" = 5.5; "Item3" = 15.6; } To use this NSDictionary Items in a Table View i have to transfer it to a NSArray , am i right? So i try: NSDictionary *dict = [myDict objectForKey:@"items"]; for (id item in dict) { [_myArray addObject:[dict objectForKey:item]]; } But _myArray keeps empty? What am i doing wrong? 回答1: Leaving aside the technical issues with the code you posted, you asked this: To use this Dictionary Items in a Table View i have to transfer it to a NSArray, am i right?

Getting NSDictionary keys sorted by their respective values

匿名 (未验证) 提交于 2019-12-03 02:13:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an NSMutableDictionary with integer values, and I'd like to get an array of the keys, sorted ascending by their respective values. For example, with this dictionary: mutableDict = { "A" = 2, "B" = 4, "C" = 3, "D" = 1, } I'd like to end up with the array ["D", "A", "C", "B"] . My real dictionary is much larger than just four items, of course. 回答1: The NSDictionary Method keysSortedByValueUsingComparator: should do the trick. You just need a method returning an NSComparisonResult that compares the object's values. Your Dictionary is

How to remove a null value from NSDictionary

匿名 (未验证) 提交于 2019-12-03 02:05:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a JSON Feed: { "count1" = 2 ; "count2" = 2 ; idval = 40 ; level = " " ; "logo_url" = "/assets/logos/default_logo_medium.png" ; name = "Golf Club" ; "role_in_club" = Admin ; } The problem is the " " that I cannot figure out how to remove from the NSDictionary before saving it to NSUserDefaults. Please help me solve this issue. Thankyou! 回答1: Iterate through the dictionary and look for any null entries and remove them. NSMutableDictionary * prunedDictionary = [ NSMutableDictionary dictionary ]; for ( NSString * key in [

Getting metadata in swift by UIImagepickerController

匿名 (未验证) 提交于 2019-12-03 02:01:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm trying to implement the answer in iOS 8 UIImage Metadata for Objective-C in SWIFT as follows //source: http://stackanswers.com/questions/24227578/ios-8-uiimage-metadata func metaDataFromAssetLibrary ( info : NSDictionary ) { var assetURL = info . objectForKey ( UIImagePickerControllerReferenceURL ) as NSURL var assetLibrary = ALAssetsLibrary () assetLibrary . assetForURL ( assetURL as NSURL , resultBlock : { ( asset : ALAsset !) in var metadata : NSDictionary = asset . defaultRepresentation (). metadata () as NSDictionary NSLog

replace a value in NSDictionary in iphone

匿名 (未验证) 提交于 2019-12-03 01:55:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a array(dataArray) of NSDictionary "item". It has datas like "david"for key "name" and "85" for key "marks" etc for 5 students.I want to replace the mark of david to 90 with respect to the array index value(ie 0 for dictionary containing david and 85).How can i do it.Please help me. EDIT: The code for content in array is [item setobject:name forkey:@"Name"]; [item setobject:mark forkey:@"Marks"]; [dataArray addOject:item] The above code goes inside parsing, so i have array with 5 objetcs(students), their name and marks , now i want to

Recursively traverse NSDictionary of unknown structure

匿名 (未验证) 提交于 2019-12-03 01:55:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Has anyone done a recursive ordered traversal of an NSDictionary of unknown structure? I'd like to take any NSDictionary and process each level in hierarchical order. 1) This data is coming from validated JSON. Is it safe to say that the NSDictionary created from a framework such as SBJSON (JSON Framework) would only result in a combination of nested dictionaries, arrays, and arbitrary leafs? 2) How can a generic traversal be done using fast enumeration that works for both arrays and dictionaries? With the code below, once I get to

NSDictionary: method only defined for abstract class. My app crashed

匿名 (未验证) 提交于 2019-12-03 01:47:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My app crashed after I called addImageToQueue. I added initWithObjects: forKeys: count: but it doesn't helped me. Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSDictionary initWithObjects:forKeys:count:]: method only defined for abstract class. Define -[DictionaryWithTag initWithObjects:forKeys:count:]!' my code - (void)addImageToQueue:(NSDictionary *)dict { DictionaryWithTag *dictTag = [DictionaryWithTag dictionaryWithDictionary:dict]; } @interface DictionaryWithTag : NSDictionary @property