Switch to a new song/audio in background for iOS

If you have a music app, you might be using a code like this to play songs in your iOS app: - (void)next { // Find new index NSUInteger newIndex; // Create a new audio player for this index NSError *error = nil; AVAudioPlayer *newAudioPlayer =[[AVAudioPlayer alloc] initWithContentsOfURL:[(MDAudioFile *)[soundFiles objectAtIndex:selectedIndex] filePath]…

PromiseKit: Promises for iOS

Most of the apps today have to deal with lot of asynchronous stuff. If you do a lot of asynchronous NSURLRequests, Restkit's getObjectsAtPath:parameters:success:failure:, or even simple asynchronous UI actions (e.g. UIAlertView and UIActionSheet), I am sure you often see the code becoming ugly, wrapped inside asynchronous…

Push Notifications in iOS8

There have been some great changes to iOS notifications with the iOS8 update. This means that now you can send a payload of upto 2KB instead of the 256 bytes earlier. iOS8 also separates the silent and UI push notifications. It means that you can send notifications without any UI…

Nested Sections in UITableView

Sometimes, there might be cases where you would like to display nested sections in a UITableView. For example, consider an app organizing groups taxonomically like so Sports Bat-and-ball Baseball Softball Cricket Hockey Field Hockey Ice Hockey Roller Hockey Engineering Computer Science Software Engineer Electrical Engineer A UITableView really isn't designed…

Best Practices for Table View Data Sources

If you read objc.io, you already know what I am talking about, lighter view controllers. Table views are heavily used in iOS apps and most of the times, all the code for handling the data source goes right in the controller. As the app starts growing, the controllers become…

Custom parallax effect for iCarousel

iCarousel is a class designed to simplify the implementation of various types of carousel (paged, scrolling views) on iPhone, iPad and Mac OS. iCarousel implements a number of common effects such as cylindrical, flat and "CoverFlow" style carousels, as well as providing hooks to implement your own bespoke effects. Lets…