ios - In Swift, NSDictionary(contentOfFile:) sometimes returns nil -
i'm developing ios keyboard extension, , load data of keyboards plist file. version ios 8.4/xcode 6.4.
but sometimes(not everytime), when in viewdidload
of inputviewcontroller
, nsdictionary(contentsoffile:)
returns nil. appears when switched between keyboard , 1 frequently.
what checked:
- the file not nil.
- the file name doesnt change @ all.
- try again while nil.
- contentsofurl instead of filepath.
- there ascii codes in plist file.
what i'm suspecting:
- file-io problems when process doesnt end properly.
- swift problems
thanks aderstedt, checked nserror.
let nsdata = nsdata(contentsoffile: file, options: nil, error: &nserror) if nserror != nil { nslog("load error: \(nserror?.description)") }
load error: optional("error domain=nscocoaerrordomain code=256 \"the operation couldn\u2019t completed. (nscocoaerrordomain error 256.)\" userinfo=0x17066c700 {nsfilepath=/private/var/mobile/containers/bundle/application/"my application", nsunderlyingerror=0x174845df0 \"the operation couldn\u2019t completed. (nsposixerrordomain error 24 - many open files)\"}")
i fixed closing other closing garbage files, , following link helpful.
on ios/iphone: "too many open files": need list open files (like lsof)
Comments
Post a Comment