ios - WatchOS: Should UI updates from the extension be called on the main thread? -


for ios apps, ui updating done main thread exclusively - not doing never recommended , can lead unexpected behaviour.

in watchos, os structured watch extension, , app - different 'containers'. usually, ui updates called extension, , these update in app's container.

does same main thread logic apply updating ui watch extension, or can ui updates called background?


edit - bring clarity. app's container, ui updates should happen on main thread (as happens in systems/oss, pointed out below). question whether watchos handles us, i.e. whether calling ui update on background thread of extension automatically posted main thread of app's container us.

apple's app programming guide watchos definitive guide, can find no reference in there regarding doing ui updates on threads other main thread.

one think if important ui updates be called main thread, explicitly state somewhere (as in app programming guide ios, in threads , concurrency section):

work involving views, core animation, , many other uikit classes must occur on app’s main thread. there exceptions rule—for example, image-based manipulations can occur on background threads—but when in doubt, assume work needs happen on main thread.

though, above quote construed true of ui updates watch extension also, since that's running on ios.

all of above say, don't believe there's apple documentation stating 1 way or other.

here's data point, though: apple's lister sample code includes watchkit extension, , brief studying of it, appears dispatching fetches background queue (see listinfo.swift: 34) , updating ui dispatching main queue (listsinterfacecontroller.swift: 98). there's comment in there saying it's doing that:

the fetchinfowithcompletionhandler(_:) method calls completion handler on background queue, dispatch main queue make ui updates.

i think based on above, i'd err on side of doing updates on main thread, unless determine there performance or other implications of doing so.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -