From the course: iOS Development Tips

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Array tricks

Array tricks

- [Instructor] For some of these tips, I'd like to get back to basics looking at some of the things we use every day but may not use all of its features. One of those is the often used array, so I'd like to show you some of the power methods you may not be using. Load the playground I've started for you. Arrays are ordered collections of a single type. I've made a couple of literal arrays here for you. One is a literal array of integers, which I called array, and I made a string array called toppings here. Underneath that I made you one more array because you don't need to just use simple types like strings and ints. You can use more complicated things such as structs and classes. I made a struct Pizza here with a topping and size. I then added three pizzas to my pizzas array, so we can use all of those for our tips today. What I'd like to cover are sorting and searching arrays which you may not have used to do something known as predicates. Sorting arrays can be as easy as using the…

Contents