Get Updates By E-mail 

Article Written By:
Johann Dowa

Swift Library Providing An Active Record Implemention For Managing Core Data Objects

  •  
  •  
  •  
  •  
  •  

Some time ago I mentioned the ObjectiveRecord library providing an active record implementation for managing Core Data objects in Objective-C.

Here’s an open source Swift library inspired by ObjectiveRecord providing an implementation of ActiveRecord with a number of nice features from Zaid Daghestani called SwiftRecord.

SwiftRecord provides easy queries, creation, deletion, and saving and you can use dictionaries.

Here is an example from the readme demonstrating the query syntax:

// grab all Events
var events = Event.all() as! [Event]

// all past events before now
var pastEvents = Event.query("when < %@", NSDate()) as! [Event]

// specific event, yes we have support for format&arguments. Note, finding specific events return optional vars
var thisEvent = Event.find("name == %@ AND when == %@", "productQA", NSDate()) as? Event

// Use dictionaries to query too
var birthdayEvents = Event.query(["type":"birthday"]) as! [Event]

// or NSPredicates
var predicate = NSPredicate("type == %@", "meeting")
var meetingEvents = Event.query(predicate) as! [Event]

You can find SwiftRecord on Github here.

A great library for working with Core Data in Swift.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments