nssortdescriptor

NSSortDescriptor - push # and numbers to the end of the list - iphone xcode

◇◆丶佛笑我妖孽 提交于 2019-12-04 04:30:14
I have a table view that shows contacts sorted by alphabetic ordering and divide it to sections. i am using - NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:[dataSource keyName] ascending:YES]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil]; then for contacts without name i am using # sign as their first letter so all of them will be grouped in one group. everything is great. the only thing i want is to push the # section to the end of the table, as for now it shows in the beginning of it. any ideas? thanks in advance shani The best

Sort NSArray with custom objects

戏子无情 提交于 2019-12-04 03:16:48
In my Xcode project I have the following classes: Address @interface LDAddress : NSObject{ NSString *street; NSString *zip; NSString *city; float latitude; float longitude; } @property (nonatomic, retain) NSString *street; @property (nonatomic, retain) NSString *zip; @property (nonatomic, retain) NSString *city; @property (readwrite, assign, nonatomic) float latitude; @property (readwrite, assign, nonatomic) float longitude; @end Location @interface LDLocation : NSObject{ int locationId; NSString *name; LDAddress *address; } @property (readwrite, assign, nonatomic) int locationId; @property

NSSortDescriptor - Sort descriptor based on another array

删除回忆录丶 提交于 2019-12-04 01:29:07
问题 I hava a core data application. And I want to fetch one kind of object, User . User have the property userId . I have another array with userId s, [1, 4, 3, 5] . And I would like to create a NSSortDescriptor that sorts my User objects based on the order of the userId s in the array. Is that possible, and how should I do that? Update I have now tried the following. I added a transformable property to my User object, where I store the user ids array. I have tried the following sort descriptor:

iPhone contacts app styled indexed table view implementation

点点圈 提交于 2019-12-03 09:15:38
My Requirement: I have this straight forward requirement of listing names of people in alphabetical order in a Indexed table view with index titles being the starting letter of alphabets (additionally a search icon at the top and # to display misc values which start with a number and other special characters). What I have done so far: 1. I am using core data for storage and "last_name" is modelled as a String property in the Contacts entity 2.I am using a NSFetchedResultsController to display the sorted indexed table view. Issues accomplishing my requirement: 1. First up, I couldn't get the

Sorting Array Using NSSortDescriptor [duplicate]

好久不见. 提交于 2019-12-03 08:02:11
This question already has answers here : How to sort NSMutableArray of date objects (3 answers) I have an array of class A objects, let it be detailsArray. Class A has date, name as properties. Can any one suggest a good method to sort this array based on date? How can I use NSSortDescriptor to sort this array? I know sorting array of dictionary using NSSortDescriptor ... Any help is greatly appreciated..... Nick C NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"date" ascending:NO]; NSArray *sortedArray = [detailsArray sortedArrayUsingDescriptors:@[sortDescriptor]]

iOS Get objects from CoreData sorted by primary key

扶醉桌前 提交于 2019-12-02 00:17:32
I have saved data into db using CoreData. I need to fetch data from my table in same order that it was saved. Inside table it is ordered by Z_PK - hidded CoreData key. How can I create such sort descriptor. If I use fetch request without sort descriptors my data objects have wrong order. Anything not exposed to you by the Core Data framework is an implementation detail. The fact that Z_PK exists, and currently suits your purposes, cannot be relied upon. If creation/save order is important to your model, then it should be included in your model. There's really nothing else to it. There is no

Sort NSFetchedResultsController result based on array?

淺唱寂寞╮ 提交于 2019-12-01 21:45:09
I would like to construct a NSPredicate or NSSortDescriptor (Core Data search) that is based on the content of an array. The array will consists of userId:s in the right order: [1, 2, 5, 3]; I would like to present the result for my NSFetchedResultsController in the same order. So I will: Get the right users (I have done this) Sort the list of users based on my sorted array with userId s. Is this possible to do, and how can I do it? Martin R I think that is not possible. Sorting the results of a fetch request (for a SQLite-based store) is done on the SQLite level, and can use only persistent

NSSortdescriptor ineffective on fetch result from NSManagedContext

跟風遠走 提交于 2019-12-01 18:47:56
I'm trying to sort my NSFetchRequest result using a NSSortdescriptor using a key pointing to a NSDate value. My fetch results come out totally random for no clear reason. The NSManagedObjectContext I'm using is updated with a save from a nested child context created on a subclass of NSOperation. I know all this is done successfully because I can get all the data needed from the parent (main) context. Fetching from it just wont sort on date! Strange thing is; predicates for selecting the entities (called "Tweet") between two dates works just fine! Here's some code to illustrate my problem:

NSSortDescriptor evaluating ascending numbers (Swift)

社会主义新天地 提交于 2019-12-01 16:48:24
App has contentid coming in as a number string from a json file: let contentid: AnyObject! = jsonFeed["contentid"] let stream:Dictionary = [ "contentId": contentid as! String, ] It is later saved to [NSManagedObject] with: var articles = [NSManagedObject]() let entity = NSEntityDescription.entityForName("Article", inManagedObjectContext: managedContext) let article = NSManagedObject(entity: entity!, insertIntoManagedObjectContext: managedContext) article.setValue(stream["contentId"], forKey: "contentid") articles.append(article) Finally, I use NSSortDescriptor to have Core Data return entries

NSSortDescriptor evaluating ascending numbers (Swift)

一曲冷凌霜 提交于 2019-12-01 15:57:23
问题 App has contentid coming in as a number string from a json file: let contentid: AnyObject! = jsonFeed["contentid"] let stream:Dictionary = [ "contentId": contentid as! String, ] It is later saved to [NSManagedObject] with: var articles = [NSManagedObject]() let entity = NSEntityDescription.entityForName("Article", inManagedObjectContext: managedContext) let article = NSManagedObject(entity: entity!, insertIntoManagedObjectContext: managedContext) article.setValue(stream["contentId"], forKey: