Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

This decoder will only decode classes that adopt NSSecureCoding

From AppDelegate i call this:

-(void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply{

    [SavedSearchesHack getAllMatches:^(MatchCollection * _Nonnull matchCollection) {
        reply(@{@"response" : matchCollection});
    }];
}

And then i get this error when calling the reply:

*** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'This decoder will only decode classes that adopt NSSecureCoding. Class 'Test.MatchCollection' does not adopt it.'

    public class func openParentApplication(userInfo: [NSObject : AnyObject], 
    reply: (([NSObject : AnyObject], NSError?) -> Void)?) -> Bool

As long as i return simply objects like "test" instead of a MatchCollection i get no error.

like image 469
Godfather Avatar asked Jul 26 '16 11:07

Godfather


1 Answers

add in .h file

 // just the protocol

@interface PacketH: NSObject<NSSecureCoding>

add in .m file

+ (BOOL)supportsSecureCoding {
   return YES;
}
like image 105
dengApro Avatar answered Nov 15 '22 03:11

dengApro