I am Ary Tebeka, serial entrepreneur and currently an Indie iOS dev (for the last 4 years). I’ll try to post in this blog things I discover while developing for iOS.

Improved Wiggling iOS 9 UICollectionView (Swift)

With iOS 9 UICollectionView now has built-in drag and drop reorder. This is very easy to enable specially when using a UICollectionViewController.

However there is no animation showing that the move operation started or finished, and worse there is no delegate call or notification to be informed of move start/end.

So here is my UICollectionView subclass which adds:

  • Wiggle animation while moving (taken from this library)
  • isWiggling read-only property to check if collection view is currently moving a cell
  • Notifications at start and end of move

Here is the code

Apple Watch ClockKit: Reload Complications Placeholder Templates

I just posted a radar to suggest an enhancement to the way ClockKit currently handles the placeholder templates for the Apple Watch complications.

Here is the text I submitted:

I am developing a watch app with complications that can be customised by the user. It would be nice for users to see a placeholder according to the data and format they customised. Currently templates are loaded only once at app install. A great improvement would be an API call from the iPhone companion app to request reloading of all (or some) of the complication templates.

Swift: should a function Throw or return an Optional?

Since Swift 2.0 we now have two ways for a function to fail:

  • It can return an Optional
  • Or it can Throw

Let’s use a very simple example: a function to return the square root of a number.
It is supposed to fail if the number was negative of course.

Return an Optional

Throw an exception

Which style do you prefer? The obvious advantage of “throw” is that we get an ErrorType with information on the reason of the failure.
On the other side, Optional results can be chained and this can make it a much more convenient choice when we don’t care about the reason for failure.