-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swift 3 support? #2
Comments
Yes, I would like to migrate it to Swift 3. I'm pretty busy right now, but I'll definitely keep you posted. |
Hi, @bradhilton! Thanks for your answer! |
Got very strange crash when created object was released. struct Post: Convertible {
let userId: Int
let id: Int
let title: String
let body: String
}
class ViewController: UIViewController {
fileprivate var post: Post? = nil
override func viewDidLoad() {
super.viewDidLoad()
let rawTitle = "sunt aut facere repellat provident occaecati excepturi optio reprehenderit" as NSString
let rawBody = "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto" as NSString
let nsDict: [JsonDictionaryKey: Any] = [
"userId": 1,
"id": 1,
"title": rawTitle as String,
"body": rawBody as String,
]
let swiftDict: [JsonDictionaryKey: Any] = [
"userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
]
do {
let postFromDict: Post = try Post.initializeWithJson(JsonValue(object: nsDict))
// let postFromDict: Post = try Post.initializeWithJson(JsonValue(object: swiftDict)) // ok, no crashes
print(postFromDict)
self.post = postFromDict
} catch {
print(error)
}
perform(#selector(ViewController.nullify), with: nil, afterDelay: 1)
}
func nullify() {
post = nil // crash here: swift_unknownRelease
}
} Everything works fine if I use Reflection let rawTitle = "sunt aut facere repellat provident occaecati excepturi optio reprehenderit" as NSString
let rawBody = "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto" as NSString
let nsDict: [String: AnyObject] = [
"userId": NSNumber(value: 1),
"id": NSNumber(value: 1),
"title": String(rawTitle) as AnyObject,
"body": String(rawBody) as AnyObject,
]
do {
let postFromDict: Post = try construct(dictionary: nsDict)
self.post = postFromDict
} catch {
print(error)
} @bradhilton, can you give me any idea where is a problem may be? |
Any plans to migrate to Swift 3? As I see, right now, it's best-written native Swift mapping framework.
The text was updated successfully, but these errors were encountered: