Parse and watchkit extension

I am creating an application using WatchKit and would like to populate the table with the data from PFObjects that I have in the class, but I got this error:

Application termination due to the uncaught exception "NSInvalidUnarchiveOperationException", reason: "This decoder will only decode classes that use NSSecureCoding. The class" PFObject "does not accept it."

Having the same issue as this post

+6
source share
2 answers

Have you considered adding a Swift extension to a PFObject that uses the NSSecureCoding protocol?

I have not tried this action, but it seems reasonable to expect this to work with an error message.

Recommended Action

To comply with NSSecureCoding:

An object that does not override initWithCoder: can match NSSecureCoding without any changes (provided that it is a subclass of another class that matches).

An object that overrides initWithCoder: must decode any private objects using the decodeObjectOfClass: forKey: method. For instance:

SWIFT

let obj = decoder.decodeObjectOfClass(MyClass.self, forKey: "myKey") 

In addition, the class must override the supportSecureCoding method to return true.

When using Objective-C, a category seems to be a suitable solution.

+3
source

In the clock controller interface, just set the Parse credentials again:

 [Parse setApplicationId:@"APPID" clientKey:@"CLIENTKEY"]; 

and create a new PFQuery for watch only. It doesn't matter if the connection fails or not.

+1
source

Source: https://habr.com/ru/post/987635/


All Articles