ios - Passing an image from iPhone to Apple Watch not working -
most tutorials on passing image talk existing images. attempting generate images @ runtime on iphone , pass apple watch.
i using mmwormhole
referenced so question didn't images through.
i've tried using + openparentapplication
on wkinterfacecontroller
directly. error:
property list invalid format: 200 (property lists cannot contain null)
i , see uiimage cannot serialized. try convert uiimage > nsdata > nsstring
, send
- (void)awakewithcontext:(id)context { [super awakewithcontext:context]; self.timer = [nstimer scheduledtimerwithtimeinterval:0.1 target:self selector:@selector(loop) userinfo:nil repeats:true]; }; - (void)loop { [wkinterfacecontroller openparentapplication:nil reply:^(nsdictionary *replyinfo, nserror *error) { nsdata *m = replyinfo[@"image"]; uiimage *img = [uiimage imagewithdata:m]; [self.image setimage:img]; }]; // [self.wormhole passmessageobject:@"hello" identifier:@"hello"]; } appdelegate - (void)application:(uiapplication *)application handlewatchkitextensionrequest:(nsdictionary *)userinfo reply:(void (^)(nsdictionary *))reply { uiimage *image = [uiimage imagenamed:@"cat.png"]; nsdata *data = uiimagepngrepresentation(image); nsdictionary *d = @{@"image" : data}; reply(d); }
you need specify app group id on both ends. like:
mmwormhole *wormhole = [[mmwormhole alloc] initwithapplicationgroupidentifier:appgroupid optionaldirectory:kwormholedirectory];
Comments
Post a Comment