grand central dispatch - IOS dispatch_async view will disappear -
i using dispatch_async , block retrieve server data every 3 seconds or so. method of handling view either disappearing or user shutting program down?
would boolean flag async block checks every , then? if so, if view exits while async block sleeping?
you cannot cancel dispatch call, best bet move nsoperation
instead. there highly relevent video wwdc 2012, session 211 - building concurrent user interfaces on ios covers precisely kind of problem describe. suggest watch it.
the basic approach create nsblockoperation
can check -iscancelled
property on return if gets cancelled. can cancel operation in viewdiddisappear
.
an alternative approach use nstimer
can invalidated/cancelled. might simplest solution given description of code doing.
Comments
Post a Comment