nsarray

Reloading UITableView shows error?

人走茶凉 提交于 2020-01-20 07:52:19
问题 I am in a strange situation . when i try to reload the tableview using reloadData() it shows the following error . . . fatal error: unexpectedly found nil while unwrapping an Optional value Here is the web service method that retrieves output func didRecieveOutput(results:NSArray) { if results.count != 0 { userOrders = results as! NSMutableArray dispatch_async(dispatch_get_main_queue(), { () -> Void in self.orderList.reloadData() }) } } Edit : I had checked my connection as well as delegate &

Are the sorting algorithms used by NSArray stable sorts?

心不动则不痛 提交于 2020-01-19 16:11:44
问题 Are the sorting algorithms used by the various sorting methods in NSArray stable? (As in are they "stable sort" algorithms, where items with the same sort key have their relative orders preserved.) 回答1: Stable sort is not guaranteed unless you use NSSortStable . From the documentation on NSSortOptions: NSSortStable Specifies that the sorted results should return compared items have equal value in the order they occurred originally. If this option is unspecified equal objects may, or may not,

Are the sorting algorithms used by NSArray stable sorts?

隐身守侯 提交于 2020-01-19 16:10:14
问题 Are the sorting algorithms used by the various sorting methods in NSArray stable? (As in are they "stable sort" algorithms, where items with the same sort key have their relative orders preserved.) 回答1: Stable sort is not guaranteed unless you use NSSortStable . From the documentation on NSSortOptions: NSSortStable Specifies that the sorted results should return compared items have equal value in the order they occurred originally. If this option is unspecified equal objects may, or may not,

How to search an NSSet or NSArray for an object which has an specific value for an specific property?

血红的双手。 提交于 2020-01-18 21:32:28
问题 How to search an NSSet or NSArray for an object which has an specific value for an specific property? Example: I have an NSSet with 20 objects, and every object has an type property. I want to get the first object which has [theObject.type isEqualToString:@"standard"] . I remember that it was possible to use predicates somehow for this kind of stuff, right? 回答1: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"type == %@", @"standard"]; NSArray *filteredArray = [myArray

How to convert json to NSArray [duplicate]

风格不统一 提交于 2020-01-17 21:36:20
问题 This question already has answers here : How to extract JSON string to array? (2 answers) Closed 3 years ago . I have a JSON array being output on a page. I would like to convert this JSON array into an NSArray. Or convert this json like : Can someone let me know what the step might be? Thank you! 回答1: Try this. NSArray *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; Or NSArray * json = [self JSONWithData:data]; +(id)JSONWithData:(NSData *)data { if (!data) { return

Sort Array of Dictionaries by NSDates within the Dictionaries

孤者浪人 提交于 2020-01-17 04:23:45
问题 I am creating an application with separate posts in it (similar to Instagram). Each post is a dictionary located in one big array. Within each dictionary their is an NSDate which I would like to sort the dictionaries by in order from newest to oldest. I have read similar questions but they are in objective C. I have a feeling NSSortDescriptor be a helpful method but am unsure on how to use it in this situation. Any help would be great, Thanks 回答1: If you’re writing in Swift, you’ll probably

Nesting arrays into NSDictionary object (Objective-C)

三世轮回 提交于 2020-01-16 18:59:24
问题 I would like to define tasks using NSDictionary, which I'd like to save in a plist file (I didn't have much luck with Core Data so far), but got stuck at two points: -- When using initWithObjectsAndKeys: I can change the data type to number or boolean, using NSDate's numberWithInt: and numberWithBool: methods, respectively. I can't seem to find the method to change the type to date though. I couldn't find anything like that in the documentation. -- The second problem I ran into was with the

Nesting arrays into NSDictionary object (Objective-C)

醉酒当歌 提交于 2020-01-16 18:58:09
问题 I would like to define tasks using NSDictionary, which I'd like to save in a plist file (I didn't have much luck with Core Data so far), but got stuck at two points: -- When using initWithObjectsAndKeys: I can change the data type to number or boolean, using NSDate's numberWithInt: and numberWithBool: methods, respectively. I can't seem to find the method to change the type to date though. I couldn't find anything like that in the documentation. -- The second problem I ran into was with the

Does Nssortdescriptor convert contents of the array to integer after sorting?

情到浓时终转凉″ 提交于 2020-01-16 09:08:36
问题 Given the below code, in the first iteration the logs are displayed normally. For the second iteration the app crashes with the following error message: 019-11-07 09:54:08.156277+0100 xxxion[520:202084] iconNumberString : 1026 2019-11-07 09:54:12.160849+0100 xxxtion[520:202084] [self.iconNumbers lastObject]) : 1026 2019-11-07 09:54:24.598805+0100 xxxion[520:202084] -[__NSSingleObjectArrayI addObject:]: unrecognized selector sent to instance 0x2824a3fd0 (lldb) The nssortdescriptor used:

Display edited NSString in order

六月ゝ 毕业季﹏ 提交于 2020-01-15 12:13:51
问题 I have been working on this for a few days with help from this great community. I have a NSArray that I need to edit NSStrings within. I have managed to detect a marker in the string and make it bold. However now I am trying to display the strings in the order that they are within the NSArray whilst maintaining the Bold that was added to the specific strings. I can display the individual Bold String ' string ' but I need it to be in order that it is within the array. I know of