The following is a test method for communicating between the watchOS and iOS components of my app:
- (void)session:(WCSession *)session didReceiveMessage:(NSDictionary<NSString *,id> *)message replyHandler:(void (^)(NSDictionary<NSString *,id> * _Nonnull))replyHandler {
NSArray *responseArray = @[@"hello", "world"];
NSDictionary *responseDict = @{@"response": responseArray};
replyHandler(response);
}
This works perfectly - in the reply handler on the watch I can log the contents of responseDict and see the objects @"hello"
and @"world"
. However, if I change responseArray to contain NSManagedObject instances (for sending actual data to the watch), the sendMessage error handler is triggered with an error saying Payload could not be delivered
. Before I change my database structure to include a uuid for the entities I need to send (so I can send them represented by their UUID in NSString format), I just wanted to check: is it actually possible to send NSManagedObject instances to watchOS?