Skip to content

Instantly share code, notes, and snippets.

@sideshowcoder
Created June 9, 2014 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sideshowcoder/48ef31df4bad66c1b152 to your computer and use it in GitHub Desktop.
Save sideshowcoder/48ef31df4bad66c1b152 to your computer and use it in GitHub Desktop.
def database
return @database if @database
manager = CBLManager.sharedInstance
error_ptr = Pointer.new(:object)
@database = manager.databaseNamed("todos", error: error_ptr)
unless @database
error = error_ptr[0]
alert = UIAlertView.alloc.initWithTitle("Local Database Error",
message:"No access to local database. #{error}",
delegate:nil,
cancelButtonTitle:"Ok",
otherButtonTitles: nil)
alert.show
else
@database
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment