core data - Swift3 CoreData with Extension -
i'm working on core data extensions, , having errors below.
terminating app due uncaught exception 'nsinvalidargumentexception', reason: 'executefetchrequest:error: not valid nsfetchrequest.'
it's working on host app still, crashing on extensions same codes.
debugger stopped when executed managedobjectcontext.fetch(request)
func getdatastring() -> string { var result = "" let entitydescription = nsentitydescription.entity(forentityname: "datastring", in: managedobjectcontext)! let request : nsfetchrequest<nsfetchrequestresult> = datastring.fetchrequest() request.entity = entitydescription { let results = try managedobjectcontext.fetch(request) printdebug(message: "\tdatastring count : \(results.count)") if results.count > 0 { let row = results[0] as! nsmanagedobject result = row.value(forkey: "data") as! string } } catch let error { printdebug(message: "error : getdatastring fetch") seterrorlog(errortext: "\(error)") } return result }
this crashes though written try-catch. please help.
the generic type of nsfetchrequest
has datastring
:
let request: nsfetchrequest<datastring> = datastring.fetchrequest() managedobjectcontext.perform { { let results = request.execute() } catch let error { ... } }
Comments
Post a Comment