ios - Create a new Realm -


i've used realm.io long time ago, you'd create or fetch existing realm passing string key (could or without.realm).

now i'm building app realm.io in swift. can't seem figure out how create new realm. in docs saw realm passing realm.configuration object has fileurl , readonly proprty (true or false).

anyways, touch empty file? or how can create new realm?

this have, named string must dynamic in case:

let config = realm.configuration(     fileurl: nsbundle.mainbundle().urlforresource(named, withextension: "realm"),     readonly: true )  return try! realm(configuration: config) 

are trying create new realm or open existing 1 readonly access?

if want create new realm can use default realm this:

let realm = try! realm() 

you can specify custom path realm should created, see more in docs.

also note realm produces files when open it, it's not idea open inside app's bundle directory. see this question if want have pre-populated realm on device.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -