nssortdescriptor

Sorting array having special characters, numbers, English and Arabic string in objectiveC

不羁的心 提交于 2019-12-25 00:38:12
问题 I am developing an iPhone application in objectiveC in which I have one array having alphanumeric, multilingual, special character data as shown below: ( { name = “#”; }, { name = “iPad”; }, { name = “عينة”; }, { name = “1”; }, { name = “أ”; }, { name = “10”; }, ) Sorting should provide me result as below, ( { name = “iPad”; }, { name = “أ”; }, { name = “عينة”; } { name = “#”; }, { name = “1”; }, { name = “10”; }, ) Means first English and Arabic should be in alphabetical ascending order then

Core Data: Sort by Relationship's Attribute

为君一笑 提交于 2019-12-24 17:53:38
问题 I'm building an open-source clone of iPhone's native Messages app called AcaniChat on GitHub. I have a Conversation entity and a Message entity with a sentDate attribute. Each Conversation can have many Message s. How do I fetch Conversation s sorted by the sentDate of it's oldest Message ? 回答1: The best way I can think of doing this is by adding an attribute to the Conversation entity called lastMessageSentDate and, every time a Message comes in and gets added to a Conversation , setting

Xcode sort array by specific (NSString) dictionary key (like sql query)

感情迁移 提交于 2019-12-24 17:14:59
问题 For example I want to sort following array based on "fruit" in the sequence of orange, kiwi, apple, mango. After that the array sort follow the ascending sequence of name among the same "fruit". <__NSArrayM 0x8aaaaa0>( { "unique" = 1; "fruit" = "apple"; "name" = "James"; },{ "unique" = 2; "fruit" = "apple"; "name" = "Jason"; }, { "unique" = 3; "fruit" = "orange"; "name" = "Peter"; } ,{ "unique" = 4; "fruit" = "kiwi; "name" = "Amy"; } ,{ "unique" = 5; "fruit" = "kiwi"; "name" = "Lionel"; } ,{

The performance of NSSortDescriptor?

坚强是说给别人听的谎言 提交于 2019-12-24 09:59:38
问题 I have a SQLite backed database of roughly 4000 rows, connected to Core Data. The model is a simple overview -> detail model. Each overview (with title and subtitle) has a relationship to a detail, which contains detailed information. To view this data I have implemented a UITableView with a NSFetchedRequestController. NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"registered_name" ascending:YES]; NSArray *sortDescriptors = [NSArray arrayWithObject:sort]; NSPredicate

Sort NSDate without respect to the time of day - just the date

不想你离开。 提交于 2019-12-24 03:07:41
问题 I have an array controller with keys of nextCheck (NSDate), lastName (NSString), and firstName (NSString). I have set the sort descriptors for the array. As you can see below, I am sorting by nextCheck first, then lastName, then firstName. This appears to not be working because the NSDate is made up of not only a date component but also a time component. Is there an easy way to sort by the date component only? [_arrayCurrentVisits setSortDescriptors:[NSArray arrayWithObjects:[NSSortDescriptor

Easy way to put blank strings at end of sort using NSSortDescriptor?

牧云@^-^@ 提交于 2019-12-24 01:57:25
问题 I'm using NSSortDescriptor to sort an NSArray of NSDictionary items. Works great, just what I needed... except that I'd like for the dictionary items that have blank values for my sort key to show up at the end of the sorted list. Is there a way to easily accomplish this? Or will I have to create some custom sorting functions? And no, I don't want to just set it to DESC order... I'd like sorted results to look like A, A, B, B, C, blanks, blank. 回答1: Figured this out after seeing another

Is it possible to have Core Data sort the “many” part of a To-Many relationship during a fetch request?

自闭症网瘾萝莉.ら 提交于 2019-12-22 17:59:32
问题 I'm using Core Data to cache a decent amount of information, and I have a To-Many relationship set up among my managed objects. Naturally I use an NSFetchRequest to fetch an array of the singular side of that relationship. However, I populate a UITableView using the the "many" side of the relationship, and I'd like it to be sorted alphabetically when I pull the data. If I'm not being clear, here's an example: "employee" and "boss" are both NSManagedObjects in a To-Many relationship - each

NSSortdescriptor, finding the path to the key I wish to use for sorting

隐身守侯 提交于 2019-12-22 17:49:15
问题 I am using an NSSortdescriptor to sort a collection of NSArrays, I then came across a case where the particular NSArray to be sorted contains an NSDictionary who contains an NSDictionary. I would like to sort from the string paired with a key in the last dictionary. This is how I would reference the string: NSDictionary *productDict = [MyArray objectAtIndex:index]; NSString *dealerName = [[productDict objectForKey:@"dealer"] objectForKey:@"name"]; How would I use the dealerName in my

Sorting core data position changes with sort descriptors for iPhone

陌路散爱 提交于 2019-12-22 06:41:31
问题 I have a CoreData entity with two attributes. One called 'position' the other called 'positionChange'. Both of them are integers where the position attribute is the current position and the positionChange is the difference between the previous position and the new position. This means that the positionChange can be negative. Now I would like to sort by positionChange. But I would like it to disregard the negative values. Currently I'm sorting it descending, which will give the result: 2, 1, 0

NSSortDescriptor not sorting integers correctly

假装没事ソ 提交于 2019-12-22 05:26:21
问题 I'm trying to sort by date then start time. Start time is minutes from midnight. So if the start time is < 100 it will not sort properly. - (NSFetchedResultsController *)fetchedResultsController { if (fetchedResultsController != nil) { return fetchedResultsController; } /* Set up the fetched results controller. */ // Create the fetch request for the entity. NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; // Edit the entity name as appropriate. NSEntityDescription *entity =