Weekly Roundup: App Architecture

Aaron Brethorst, June 21, 2014

If you've been around the iOS world for a while, you've undoubtedly heard folks grumbling (or you've done some grumbling of your own) about the typical state of Apple's sample code. Don't get me wrong, there are occasionally absolute gems, like UIImage+ImageEffects (which has probably been added to half of the apps on the App Store today...), but it seems like these are few and far in between. One of the biggest omissions, in my opinion, has been the lack of sample code from Apple demonstrating how to properly manage data sources for your collection views and table views. Yeah yeah, I know what you're thinking, "what's there to know? I create a view controller with a table view, and then just set the datasource and delegate to self. Easy." And this is a fair thing to do for simpler cases, but when you start building up more complicated rules for populating your tables and collections, or when you want to reuse the view controllers, things can get hairy in a hurry.

Traditionally, to solve this sort of problem, I've always created a subclass of NSObject that implements UITableViewDataSource, and then created a new instance of the data source object, handed it to the table view, and continued on. And this works really well, but I've still suffered from a lack of best practices on which I can rely. Luckily, there was a session at WWDC this year that addressed just this issue, and provided some guidance around how Apple engineers have solved this problem in an app that Apple ships. And there's sample code, too!

Needless to say, this session, WWDC Session 232: Advanced User Interfaces with Collection Views, was one of the best I attended this year. Ole Begemann apparently agrees, and blogged about the talk at some more length. I highly recommend watching the session video and checking out the sample code. It's a great way to both promote code reuse and disentangle more complex relationships within your apps. Make sure you check it out!

Best,
Aaron


What We're Reading


Control of the Week

DZNEmptyDataSet

DZNEmptyDataSet

A drop-in UITableView/UICollectionView superclass category for showing empty datasets whenever the view has no content to display.

It will work automatically, by just conforming to DZNEmptyDataSetSource, and returning the data you want to show. The -reloadData call will be observed so the empty dataset will be configured whenever needed. It is (extremely) important to set the dataSetSource and dataSetDelegate to nil, whenever the view is going to be released. This class uses KVO under the hood, so it needs to remove the observer before dealocating the view.

MIT licensed.

Find out more Add to Favorites  See a Video


Weekly Roundup

RACollectionViewReorderableTripletLayout

RACollectionViewReorderableTripletLayout

The custom collectionView layout that can perform reordering of cells by dragging it.

pod 'RACollectionViewReorderableTripletLayout'

MIT licensed.

Find out more Add to Favorites


MZBookshelfCollectionViewLayout

MZBookshelfCollectionViewLayout

Bookshelf like iBooks layout for UICollectionView.

MIT licensed.

Find out more Add to Favorites


GSIndeterminateProgressBar

GSIndeterminateProgressBar

iOS control that acts like indeterminate progress bar

MIT licensed.

Find out more Add to Favorites


LKAssetsLibrary

LKAssetsLibrary

LKAssetsLibrary provides grouping / filtering / sorting functions for ALAssetsLibrary.

MIT licensed.

Find out more Add to Favorites


PI_EmojiPicker

PI_EmojiPicker

Simple NSView or NSViewController based picker for Emoji.

I took the wonderful work of AGEmojiKeyboard (https://github.com/ayushgoel/iOS-emoji-keyboard) as a base to create an OS X version.

Its extremely simple and worth a couple hours of work. Its useful if you want to allow a user to enter Emoji without having to use the "special keyboard" in the edit menu.

An example would be like Messages/iChat which has a smiley face picker next to the text entry.

MIT licensed.

Find out more Add to Favorites


Tattle-UI

Tattle-UI

As a developer, we struggle to understand and reproduce few UI bugs reported by the beta-tester. In tester's point of view, tester writes paragraphs to explain a simple UI misalignment when they test.

Tattle-UI solves this problem by providing simpler mechanism to get UI feedback from beta-testers.

MIT licensed.

Find out more Add to Favorites


btSimpleRippleButton

btSimpleRippleButton

This is a custom button for iOS with a ripple effect. It is simple to integrate and is customizable. Supports a callback using blocks.

MIT licensed.

Find out more Add to Favorites


HRColorPicker

HRColorPicker

RColorPicker is a lightweight color picker for iOS that's easy to use for both users and developers.

http://hayashi311.github.io/Color-Picker-for-iOS/

BSD licensed.

Find out more Add to Favorites


AKTagsInputView

AKTagsInputView

A convenient input view for seek and selecting, and writing tags data.

Features:

  • write your own tags
  • forbidden symbols settings
  • space or comma separation
  • lookup-like accessory input view
  • fast seek by first letters

Apache 2.0 licensed.

Find out more Add to Favorites  See a Video


LMGeocoder

LMGeocoder

Simple wrapper for geocoding and reverse geocoding, using both Google Geocoding API and Apple iOS Geocoding Framework.

MIT licensed.

Find out more Add to Favorites


Glyphish Gallery

Glyphish Gallery

Browse and search through your Glyphish icons in style.

Supports OS X 10.8+.

License unspecified.

Find out more Add to Favorites


VideoCover

VideoCover

A simple demo to add video in the background

Apache 2.0 licensed.

Find out more Add to Favorites


RSPOPPickerSheet

RSPOPPickerSheet

Fullscreen pop-able and block-able picker sheet.

PROBLEM

In one of my working projects, I need to show a picker view in a UITableViewController's tableView, so I add a picker view as a subview of the tableView. The result is this picker view will be scrolled together with the tableView.

HOW TO SOLVE THIS

We need a control which can show like modal and block actions, so here comes UIActionSheet. And we have to customize the UIActionSheet to show the picker view.

As we all know, the UIActionSheet can't be dragged into a empty xib, but UIView can. so we start with an UIView and do the layout and then change the class name of the UIView to UIActionSheet. That works fine for some UIView based controls.

MIT licensed.

Find out more Add to Favorites


JPRequest

JPRequest

JPRequest is a simple Objective-C object to send and receive POST and GET data from a webservice

MIT licensed.

Find out more Add to Favorites


UAProgressView

UAProgressView

UAProgressView is a simple and lightweight, yet powerful animated circular progress view.

MIT licensed.

Find out more Add to Favorites


Swift Spaceship Operator

Swift Spaceship Operator

Contains a Swift file to add the spaceship operator ( <=> ) to a project

6.0 <=> 17.0 // Outputs -1

9001.0 <=> 9000.0 // Outputs 1

4.0 <=> 4.0 // Outputs 0

Works on iOS and OS X but the Xcode project is set up as an OS X command line tool.

MIT licensed.

Find out more Add to Favorites


INSSearchBar

INSSearchBar

An animating search bar.

Originally developed for ShopNow v2. (http://www.shopnow.de)

The search bar is designed as a standalone component that can be easily drag'n'dropped into any existing iOS project.

For a story behind this control see http://salanki.com/insomniac/2014/06/03/the-search-bar-experiment/

License unspecified.

Find out more Add to Favorites


BWTitlePagerView

BWTitlePagerView

Recreate the Twitter navigation controller pager.

Apache 2.0 licensed.

Find out more Add to Favorites


TMConsecutiveDayHelper

TMConsecutiveDayHelper

A pretty basic implementation to help keep track of a users streak of days where he/she has launched your app.

The component uses NSUserDefaults to keep track of the dates. It also makes use of NSDate+Helpers category used in the PMCalendar repo here: https://github.com/kovpas/PMCalendar which is MIT Licensed.

Install:

Copy TMConsecutiveDayHelper.h and TMConsecutiveDayHelper.m into your project as well as NSDate+Helpers.h and NSDate+Helpers.m.

Place a call to:

[TMConsecutiveDayHelper appLaunched];

In your App Delegate's application didFinishLaunchingWithOptions: method

Then to check on your users streak you can call:

[TMConsecutiveDayHelper streakSizeInDays]; Or Alternatively call:

[TMConsecutiveDayHelper hasComeBackForThisExactNumberOfDaysConsecutively:5] which returns a BOOL

There's no logic as of yet to reset the streak but it could be added quite easily. basically you're responsible for what you want to do with the info and the class just keeps track of the streak itself.

Downsides:

Because the app uses NSUserDefaults it could be gamed pretty easily, by the user changing the date on their device. The component also uses ARC so if your project is using reference counting (ie retain release) then place the compiler flag ' -fobjc-arc ' inside the TMConsecutiveDayHelper.m row under the 'Compile Sources' located within the 'Build Phases' Tab for your App/Target settings.

MIT licensed.

Find out more Add to Favorites


ODSAccordionView

ODSAccordionView

Yet another accordion style container view.

MIT licensed.

Find out more Add to Favorites


btSimplePopUp-Menu

btSimplePopUp-Menu

This is a simple popup menu for iOS. Inspired by iOS7 grouping folder (loook alike) in the springboard. Is is purely based on UIView. Includes flats looks, callbacks using blocks & several options for curved corners & flat corners, bordered popup. This control supports paging using scrolls, so that user can add n number of menu items to the popUp.

Any menu when selected creates a ripple effect on the tapped item.

Simple to use, easy to integrate.

MIT licensed.

Find out more Add to Favorites


BHTKeyboardAnimationBlocks

BHTKeyboardAnimationBlocks

UIViewController category making life easier when working with animations on keybard appearing/disappearing. Provides a simple block based API to set animations to be performed on each of UIKeyboardNotifications.

MIT licensed.

Find out more Add to Favorites


MNTPullToReact

MNTPullToReact

MNTPullToReact is an extended evolution of the famous Pull to Refresh interaction.

Apache 2.0 licensed.

Find out more Add to Favorites


AFBlurSegue

AFBlurSegue

Custom UIStoryboardSegue implementation for blurring the background of a modal view controller

MIT licensed.

Find out more Add to Favorites