nsarray

Sort NSArray custom object on multiple properties

喜你入骨 提交于 2019-12-12 04:14:01
问题 I have a custom object with multiple properties. One property is a Type, for example an enum: A, B, C etc These all have a Date too. @property (assign) CustomType customType; @property (nonatomic, strong) NSDate *startDate; ... typedef NS_ENUM(NSInteger, CustomType) { A, B, C }; I would like to put all objects of type 'C' first then order the rest by their Date DESC. What is the best way to achieve this? I've tried adding multiple sortDescriptors but I only want C objects at the top, then the

Sort NSArray custom objects by another NSArray custom objects

て烟熏妆下的殇ゞ 提交于 2019-12-12 03:50:03
问题 I have 2 different NSArray with custom objects as follows, Item *item1 = [[Items alloc] init]; item1.number = @"1"; item1.serailNumber = @"S01"; Item *item2 = [[Items alloc] init]; item2.number = @"2"; item2.serailNumber = @"S02"; Item *item3 = [[Items alloc] init]; item3.number = @"3"; item3.serailNumber = @"S03"; Item *item4 = [[Items alloc] init]; item4.number = @"4"; item4.serailNumber = @"S04"; Item *item5 = [[Items alloc] init]; item5.number = @"5"; item5.serailNumber = @"S05"; NSArray

Which Object's Array Has Most of Particular Object

£可爱£侵袭症+ 提交于 2019-12-12 03:48:06
问题 I have an Object that contains many pieces of information, a Title String, Date String, and NSArray, amongst others. This Object has 8 different sets of this information. I want to find out which Set's Title has the most occurrences of the word "Sunday". After the data loads, I run some calculations: NSArray *yourArrayhere = self.theObject[@"DatesSuggested"]; int occurrences = 0; for(NSString *string in yourArrayhere){ occurrences += ([string isEqualToString:@"Sunday"]?1:0); //certain object

NSArray Returning String Instead of Dictionary

自作多情 提交于 2019-12-12 03:43:34
问题 I've setup logs and checked the code and NSArray is being returned as a string instead of a dictionary. The problem is that I'm not sure how I can convert this particular string into a dictionary and I'm running on a tight timeframe. Here's the code: NSArray* placeJson = [NSJSONSerialization JSONObjectWithData:jsonResponse options:kNilOptions error:nil]; for (NSDictionary *placeJsons in placeJson) { NSLog(@"%@",NSStringFromClass([placeJsons class])); page = placeJsons[@"page"]; NSLog(@"%d"

UITableView Dynamically Create Sections from NSArray

我是研究僧i 提交于 2019-12-12 03:26:17
问题 I have the following data structure, which I cannot change (probably the most important part of this question): <?xml version="1.0" encoding="us-ascii"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <array> <dict> <key>FirstName</key> <string>John</string> <key>LastName</key> <string>Adams</string> </dict> <dict> <key>FirstName</key> <string>Henry</string> <key>LastName</key> <string>Ford</string> </dict> </array>

how to append array. or how can i convert model to nsmuttable array

ε祈祈猫儿з 提交于 2019-12-12 02:42:39
问题 in my app i am using alamofire object mapper for use MVC structure. now i am getting one array and i fit it in model class. here is model class class OrderDetailSecond: Mappable { var id : Int? var isRxMedicine : Int? var medicineTypeId : String? var name : String? var orderId : String? var price : String? var quentity : Int? var strength : String? required init?(_ map: Map){ } func mapping(map: Map) { id <- map["id"] isRxMedicine <- map["is_rx_medicine"] medicineTypeId <- map["medicine_type

Using NSPredicate get only values of a particular key from an array of dictionaries

大兔子大兔子 提交于 2019-12-12 02:23:55
问题 I do not know the values. I only know the key. arrTripCat : ( { tripcategory = "general_tourism"; }, { tripcategory = nightlife; }, { tripcategory = "art_museums"; }, { tripcategory = nightlife; }, { tripcategory = architecture; }, { tripcategory = nightlife; } ); The NSPredicate I tried : NSArray *arrTripCat = [NSArray arrayWithArray:[self.dictSearchResult objectForKey:@"TripCategories"]]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY SELF.@allKeys contains[cd] %@",@

Word output based on NSString sequences

做~自己de王妃 提交于 2019-12-12 01:26:35
问题 What I want to do is take 3 letter word sequences from an NSString, and change them in to corresponding words. EX) AUG = "START", AGC = "Asparagine", etc. My thought was to change the NSString in to an NSArray with each element containing 3 letters, where I can then reference them in a for loop, to make a new string with the Resulting words. Example: NSDictionary *aminoReplaceDict = @{ @"AAA" : @"Lysine", @"AAC" : @"Asparagine", @"AAG" : @"Lysine", @"AAU" : @"Asparagine", @"ACA" : @"Threonine

sort on nsdictionary is giving different result than sort on nsarray

无人久伴 提交于 2019-12-12 01:03:03
问题 2 days ago I asked the question how to sort elements by second word in string object and i got solution here but now I stuck into new issue Consider I have nsarray with--> names and nsdictionary with same-->names(of nsarray) as value and email id as key And my nsarray contains "Test Teacher" "Anonymous" "Dok Teacher" and my nsdictionary contains "Dok Teacher" --"a@g.com" "Anonymous" -- "b@g.com" "Test Teacher" --"c@g.com" As I was needed to sort these array and dictionary i sorted them using

Objective C: how to convert nested NSDictionarys and NSArrays to URLEncoded string

Deadly 提交于 2019-12-12 00:32:13
问题 I have a Symfony2 project serving both a JQuery Web client and an Objective C iPhone APP. JQuery sends properly its urlencoded data to the server. Data that is properly accessed in the Symfony2 Controller using $this->getRequest()->get('myKey'); . Therefor, data is sent in application/x-www-form-urlencoded . In order not to change my Symfony Controllers (that happens to be the the whole API of my system and has around 200 AJAX calls in the form I described before), I'd like the Objective C to