Skip to content

Swift: Update Docs/Example Repos with use of dynamic keyword #46

@natevecc

Description

@natevecc

Was running into an issue where objects weren't updating when saving to the server. I managed to figure out that Swift doesn't support KVO out of the box: docs(see section Key-Value Observing).

Long story short when using Swift with the cloudmine-ios library make sure to add dynamic in objects that extend CMObject:

class MyClass: CMObject {
  // the right way. changes to this property will be picked up by KVO, the object will be marked 
  // dirty and saved when calling #save() or #saveWithUser()
  dynamic var myProperty: String?

  // the wrong way. changes will not be picked up by KVO and the object will never be marked 
  // as dirty and saved correctly
  var anotherProperty: String?
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions