michaelarmstrong / SuperRecord

A small set of utilities to make working with CoreData and Swift a bit easier.
MIT License
366 stars 27 forks source link

Nil pointer Exception if target contains a space #36

Open PGLongo opened 9 years ago

PGLongo commented 9 years ago

If the target as a name with space like "Super Record" iOS replace the space with an "_" so the correct name for the model become "Super_Record.momd"

I have solved temporarily changing:

let infoDictionary = NSBundle.mainBundle().infoDictionary as NSDictionary?
let stackName = (infoDictionary!["CFBundleName"] as! String)
let storeName = stackName + ".sqlite"

with

let infoDictionary = NSBundle.mainBundle().infoDictionary as NSDictionary?
let stackName = (infoDictionary!["CFBundleName"] as! String).stringByReplacingOccurrencesOfString(" ", withString: "_")
let storeName = stackName + ".sqlite"

@michaelarmstrong you should considering it if you are writing the new stack.

michaelarmstrong commented 9 years ago

Tackling this as part of the Stack refactor.