From the course: iOS Development Tips

Unlock this course with a free trial

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

Deep dive into dictionaries

Deep dive into dictionaries

From the course: iOS Development Tips

Deep dive into dictionaries

- [Instructor] In many factory methods, you'll find parameters with type Any optional, like you see here, user info parameters in iOs and context in WatchOS use these. You can place anything there, but most often you'll use a dictionary of type string Any. This is a great way of moving multiple values from one method to another without making a class to do so. If you've never used them before, they might be a bit of a struggle to unwrap, so let me show you how. You'll find the starter playground is a GitHub download. I'll shut down automatic running for now, and get rid of the console. I made three dictionaries at the bottom here that we'll use that has this very common type of dictionary of String:Any. Above the three dictionaries of the playground, I added a class with a few properties: an initializer and a showOrder to print that all out. My initializer is currently blank, and I'll unwrap that Any inside the init, and then populate my properties from it up here. Since Any can…

Contents