ios - Swift NSObject subclass get BAD_ACCESS -
i try persiste object nscoding bad_access error avoid multi multiple variable, class, put common variable in robject. think wrong the init don't know what.
the error thow in function
func parseinfo(allinfos : string) -> void { if let : json = json.parse(allinfos) json? { if let info = all.asarray { description in info { var track : rinfo = sctracks(js: description) self.arraytracks.addobject(track) } // therad 1: exc_bad_access(code=2, address=0x27...) } } }
the log doesn't show thing
my common class
class robject : nsobject, nscoding { var id : int? = 0 var kind : string? override init() { super.init() } init(js :json) { self.kind = js["kind"].asstring self.id = js["id"].asint super.init() } required init(coder adecoder: nscoder) { self.id = adecoder.decodeintegerforkey("id") int self.kind = adecoder.decodeobjectforkey("kind") as? string } func encodewithcoder(acoder: nscoder) { acoder.encodeinteger(self.id!, forkey: "id") acoder.encodeobject(self.kind, forkey: "kind") } }
my class rinfo inherits robject
class rinfo : robject { var title :string? var uri :string? var license :string? var release :string? var user :ruser! override init() { super.init() } required init(coder: nscoder) { self.title = coder.decodeobjectforkey("title") as? string self.user = coder.decodeobjectforkey("user") ruser self.license = coder.decodeobjectforkey("license") as? string self.uri = coder.decodeobjectforkey("uri") as? string self.release = coder.decodeobjectforkey("release") as? string super.init(coder: coder) } init(js :json) { self.user = js(js: js["user"]) self.title = js["title"].asstring self.license = js["license"].asstring self.uri = js["uri"].asstring self.release = js["release"].asstring super.init(js: js) } override func encodewithcoder(encoder: nscoder) { encoder.encodeobject(self.title, forkey: "title") encoder.encodeobject(self.user, forkey: "user") encoder.encodeobject(self.uri, forkey: "uri") encoder.encodeobject(self.license, forkey: "license") } }
thanks !
i solve problem remove variable release
in rinfo
. strange
Comments
Post a Comment