i faced issue project written in swift, when updated xcode latest version; xcode 7.0.
xcode told me should convert code work swift's new syntax (swift 2).
the problem not understand how solve line of codes.
as example: i'm using swiftyjson in application , xcode gives me error see below:
public struct json { public init(data:nsdata, options opt: nsjsonreadingoptions = .allowfragments, error: nserrorpointer = nil) { if let object: anyobject = nsjsonserialization.jsonobjectwithdata(data, options: opt, error: error) { self.init(object) } else { self.init(nsnull()) } }
some functions dropped arguments , in case error pointer. instead throws (which means can call try catch handling). here swift 2.0 version of code
public struct json { public init(data:nsdata, options opt: nsjsonreadingoptions = .allowfragments, error: nserrorpointer = nil) { { let object:anyobject = try nsjsonserialization.jsonobjectwithdata(data, options: opt) self.init(data: object as! nsdata) } catch { //error handling code } } }
Comments
Post a Comment