Finding all files

- In other code clinics and other programming languages,…I would have to talk a lot about recursion…to solve this problem.…Because if we have an unknown folder structure…where we don't know how many levels it goes down,…we would typically search this…by writing some recursive code,…having a function that can repeatedly call itself…to handle multiple levels of nesting.…I have some pseudocode here.…So we call some search directory function…passing the name of the top folder,…and then go through that checking each item…inside that folder.…And if that item is itself a subfolder, a directory,…we would call the same function,…passing in that subfolder name.…

We would drop into that folder, process…each item inside it.…If any of those are subfolders,…we would call the function again,…et cetera, et cetera, until we've gone down…all of the levels and all of the items are checked.…But for us, this ain't a problem.…Because in Swift or Objective-C,…if we want to find every file in a directory,…even if that directory has multiple levels…

Resume Transcript Auto-Scroll

Author

Updated

6/25/2015

Released

4/23/2015

Successful programmers know more than a computer language. They also know how to think about solving problems. They use "computational thinking": breaking a problem down into segments that lend themselves to technical solutions. Code Clinic is a series of ten courses where authors solve the same problems using different programming languages. Here, Simon Allardice works with Swift.

Simon introduces challenges and then provides an overview of his solutions in Swift. Challenges include topics such as statistical analysis, searching directories for images, and accessing peripheral devices.

Visit other courses in the series to see how to solve the exact same challenges in languages like C++, C#, JavaScript, PHP, Python, R, and Ruby.

Skill Level Intermediate

4h 30m

Duration

164,313

Views

Show MoreShow Less

Q: I am unable to access the Lake Pend Oreille data from outside the U.S.

A: A static copy of this data is provided here for lynda.com members outside of the U.S