Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WatchOS2 WCSession How many delegates can the WCSession have in WatchKitExtension?

My iOS app sends timely information via the WatchConnectivity framework. The receiving side implements the delegate of WCSession.

I have 2 interfaceControllers that need the information sent from the WCSession.

One is the glanceInterfaceController and the other is my mainInterfaceController.

Can both of them be assigned the delegate and both receive the userInfo or applicationContext sent from my iOS app at the same time? or can there only be one WCSession delegate assigned and my controllers need to get the data from the object that is assigned?

Thanks!

like image 254
Jacky Wang Avatar asked Jul 03 '15 11:07

Jacky Wang


1 Answers

WCSession only supports a single delegate at a time. If you want multiple parts of your code to be notified when there is new incoming content you'd have to either create a wrapper class that has similar callbacks to the WCSessionDelegate but supports multiple observers or you could use local notifications to forward the contents on. Perhaps better; have your WCSessionDelegate update the app's data store and then notify the parts of your code reading from the data store that it has been updated so they'll refresh their views?

like image 93
ccjensen Avatar answered Sep 21 '22 20:09

ccjensen