Tuesday, December 10, 2013

beginBackgroundTaskWithExpirationHandler

We can use beginBackgroundTaskWithExpirationHandler to ensure that a task doesn't get stopped abruptly This is how I used 

- (void)didReceiveObjList:(CFDataRef)message
{
    // Received List Of Objects. Processing the list can take a few seconds.
    // So doing it in separate thread with expiration handler to ensure it gets some time    to do the task even if the app goes to background.

        UIApplication *application = [UIApplication sharedApplication];
__block UIBackgroundTaskIdentifier bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
[application endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
    
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         [self processObjList:message];
[application endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
});

NSLog(@"Main Thread proceeding...");

}

Monday, December 9, 2013

UITableViewWrapperView in iOS7

In iOS7, a view is included in between UITableView and UITableViewCell, named UITableViewWrapperView. [This was not there till iOS 6].

UITableViewWrapperView is a superview of the UITableViewCell, and UITableView is the superview of UITableViewWrapperView

UITableView - > UITableViewWrapperView -> UITableViewCell