Improving Scattered: Time Profiling in Instruments

Open the Scattered project from the previous chapter and find addImagesFromFolderURL(_:) in ViewController.swift. Find the allowedFiles variable, which is used to limit the number of files opened to ten. Remove all traces of allowedFiles and run the application.

You should see the Scattered app’s icon bouncing in the dock for several seconds. When the window appears, all the images will already have been animated to their destinations. It looks like loading the images is blocking the main thread, which is a poor user experience. You may have a pretty good idea that the problem is related to loading images, since you just removed the limit, but let’s prove it.

Introducing Instruments ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.