Skip to content

Instantly share code, notes, and snippets.

@cbess
Created February 14, 2015 07:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbess/5892062783998b67056e to your computer and use it in GitHub Desktop.
Save cbess/5892062783998b67056e to your computer and use it in GitHub Desktop.
Realm Helper
import Foundation
/**
Provides the default transaction block for perform a Realm transaction.
:param: block The block to perform the transaction. The realm is used to store the transaction.
*/
func realmTransaction(block: (realm: RLMRealm) -> Void) {
let realm = RLMRealm.defaultRealm()
realm.beginWriteTransaction()
block(realm: realm)
realm.commitWriteTransaction()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment