Skip to content

Instantly share code, notes, and snippets.

@pocketkk
Created July 27, 2014 17:51
Show Gist options
  • Save pocketkk/db5895d64a212a6e9ea1 to your computer and use it in GitHub Desktop.
Save pocketkk/db5895d64a212a6e9ea1 to your computer and use it in GitHub Desktop.
Swift - Sort objects by date field
@objc(Note)
class Note: NSManagedObject {
@NSManaged var content: String
@NSManaged var date: NSDate
@NSManaged var business: Business
@NSManaged var coldcall: ColdCall
@NSManaged var contact: Contact
}
let notes : [Note] = //array of notes
// sort a collection of notes by date
notes.sort({$0.date.timeIntervalSinceNow > $1.date.timeIntervalSinceNow})
@miladgolchinpour
Copy link

Thank you so muccch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment