Skip to content

Add new no-Optional property cause crash. #92

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

Merged
merged 1 commit into from
Nov 3, 2018
Merged

Add new no-Optional property cause crash. #92

merged 1 commit into from
Nov 3, 2018

Conversation

yeseni-today
Copy link
Contributor

// before
class A: Object {
    @objc dynamic var id: String = UUID().uuidString
}
// after
class A: Object {
    @objc dynamic var id: String = UUID().uuidString
    @objc dynamic var updatedAt: Date = Date()
}

Two Device. iPhone and iPad
using iPhone nothing error. and upload some record to cloudKit.
using iPad error. I get a crash. A.updatedAt.setter error.

I think updatedAt value in CloudKit is nil

// CKRecordRecoverable.swift parseFromRecord
recordValue = record.value(forKey: prop.name) as? Date // updatedAt is nil
o.setValue(recordValue, forKey: prop.name) // prop is no-optional. setter will get a error

so I try blow code and no error.

     if recordValue != nil || (recordValue == nil && prop.isOptional) {
                o.setValue(recordValue, forKey: prop.name)
            }

@caiyue1993
Copy link
Owner

Hi @aollio , you were doing good job. This is indeed a bug in IceCream. I'll recheck later and merge this. Thank you!

@caiyue1993 caiyue1993 merged commit 7fa6963 into caiyue1993:master Nov 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants