Proper use of beginBackgroundTaskWithExpirationHandler

If you want your network transaction to continue in the background, then you’ll need to wrap it in a background task. It’s also very important that you call endBackgroundTask when you’re finished – otherwise the app will be killed after its allotted time has expired. Mine tend look something like this: – (void) doUpdate { … Read more

How to run certain task every day at a particular time using ScheduledExecutorService?

As with the present java SE 8 release with it’s excellent date time API with java.time these kind of calculation can be done more easily instead of using java.util.Calendar and java.util.Date. Use date time class’s i.e. LocalDateTime of this new API Use ZonedDateTime class to handle Time Zone specific calculation including Daylight Saving issues. You … Read more

Getting a “This application is modifying the autolayout engine from a background thread” error?

It needs to be placed inside a different thread that allows the UI to update as soon as execution of thread function completes: Modern Swift: DispatchQueue.main.async { // Update UI } Older versions of Swift, pre Swift 3. dispatch_async(dispatch_get_main_queue(){ // code here }) Objective-C: dispatch_async(dispatch_get_main_queue(), ^{ // code here });