nsdictionary

iPhone Obj C — Sorting a Mutable Array of dictionaries — display a string but sort by value

六月ゝ 毕业季﹏ 提交于 2020-01-01 06:37:07
问题 I have a NSMutableArray with 30 dictionaries inside of it. Each contains a name and a value. I currently have the names sorted so that the show in a table view alphabetically. However, I'd like to make a UIButton to give the option of STILL DISPLAYING THE NAMES, but ordered by the value. The value doesn't need to be displayed. Also, where in the .m/.h files would these codes be placed? THANKS! 回答1: To be able to help you I need a test data to work with. Let's say your array with data looks

UICollection View - Segue - did select specific cell , LOG

流过昼夜 提交于 2020-01-01 05:44:23
问题 I am starting to use a UICOllectionview to load a custom made photo album, the album loads just fine, and the data is coming from my server (SQL-JSON-NSARRAY-NSDictionary) and been populated in the cell's just fine, However now I would like it when the user selects that cell to load a new UIVIewController with that image in full size (so they can view/print/share etc) However I am getting stuck in the 'prepare for segue' method, as I cannot pull any information from that specific cell as a

Unable to use 'class' as a key in NSDictionary

心不动则不痛 提交于 2020-01-01 04:11:07
问题 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

Type '[String, AnyObject?]' does not conform to protocol AnyObject?: why?

梦想的初衷 提交于 2020-01-01 02:27:05
问题 I'm trying to understand why I have a compilation error: Type '[String, AnyObject?]' does not conform to protocol AnyObject? var cars: [String: AnyObject?] = [ "model": "Ferrari"] var JSON: [String: AnyObject?] = [ "cars": cars ] // <-- error It seems like cars is not an AnyObject? which I don't understand. Thanks for your help! 回答1: AnyObject must be a class, but Dictionary is a structure. The Swift Programming Language: Type Casting AnyObject can represent an instance of any class type. The

NSDictionary Key For Value/Object? [duplicate]

我怕爱的太早我们不能终老 提交于 2019-12-31 10:56:11
问题 This question already has answers here : How to get the key for a given object from an NSMutableDictionary? (4 answers) Closed last month . Can we get the key for an object in an NSDictionary by passing a particular value or object? 回答1: -[NSDictionary allKeysForObject:] returns an NSArray of all the keys whose objects match the passed object, where "match" is determined by isEqual: . 回答2: To answer you question in a more specific manner, use the following to get a key for a particular object

NSDictionary order does not match allKeys order

╄→гoц情女王★ 提交于 2019-12-31 07:40:45
问题 I've created NSDictionary of sorted arrays by name organized by first letter (see results below). When I use the command allKeys for that same Dictionary, the order is not the same. I need the order the same because this NSDictionary is used in UITableview and should be alphabetical. - (NSDictionary*) dictionaryNames { NSDictionary *dictionary; NSMutableArray *objects = [[NSMutableArray alloc] init]; NSArray *letters = self.exhibitorFirstLetter; NSArray *names = self.exhibitorName; for

Maintaining the order while iterating a NSDictionary

会有一股神秘感。 提交于 2019-12-31 07:12:29
问题 I have a NSDictionary which im iterating and Im saving the datas to core data as follows, NSDictionary *details = [valueDict objectForKey:@"shipment_master"]; for (NSDictionary *response in details) { NSManagedObjectContext *context = [self managedObjectContext]; // remove all rows [context performBlockAndWait:^{ // add new row(s) NSManagedObject *master = [NSEntityDescription insertNewObjectForEntityForName:@"ShipmentMaster" inManagedObjectContext:context]; NSError *error; [master setValue:

How to save a NSMutableDictionary into a file in documents?

别等时光非礼了梦想. 提交于 2019-12-31 04:00:51
问题 I would like to save the content of a NSMutableDictionary object to a file. How do I do this ? I already know how to do this task with a NSDictionary object but I don't know how to convert/copy this NSMutableDictionary to a NSDictionary...unless there's a method to write directly the content of NSMutableDictionary to a file...I stress that the NSMutableDictionary object contains objects of NSDictionary type. Thx for helping, Stephane 回答1: NSMutableDictionary is a subclass of NSDictionary :

Non-string key in NSDictionary object?

帅比萌擦擦* 提交于 2019-12-31 03:46:21
问题 I've parsed some JSON data using NSJSONSerialization from the Foundation framework - however, I'm getting a weird key for an NSDictionary group as follows "stop_times" = ( { "departure_time" = "5:48a"; "departure_timestamp" = 1355309284; "service_id" = 1; shape = "Scarborough RT To Kennedy Station"; } Any idea what the key "shape" might be? Is it a string? I didn't think so since it wasn't surrounded with double quotation marks. Thanks for your help in advance! 回答1: The description method of

insertObject: atIndex: - index 3 beyond bounds for empty array

不打扰是莪最后的温柔 提交于 2019-12-30 07:21:09
问题 I create an array based on a dictionaries key's: factsBuiltArray = [NSMutableArray arrayWithCapacity: 6]; if ([statusDict count] == 10) { for (NSString *key in [statusDict allKeys]) { if ([key isEqualToString: @"currenciesAndConversions"]) { [factsBuiltArray insertObject:key atIndex: 0]; } else if ([key isEqualToString: @"languageAndTranslations"]) { [factsBuiltArray insertObject:key atIndex: 1]; } else if ([key isEqualToString: @"plugSize"]) { [factsBuiltArray insertObject:key atIndex: 2]; }