From the course: iOS Development Tips
Unlock this course with a free trial
Join today to access over 24,000 courses taught by industry experts.
Working with sets
- [Instructor] One of the most underrated collection types is sets. Sets are an unordered collection with unique values. Let's take a look at what you can do with sets. Download the exercise file, and you'll find I created a playground with a struct called pizza here. I've made several pizzas for you, which you can see down here. Currently this is all arrays, but does it have to be arrays? Ask yourself three questions. Do I need ordered values? Do I need unique values? And do I need access directly to any value? A pizza is a good example of where a set works well. An ingredient is just an ingredient. There's no good reason to list it twice. And it also has no particular order for toppings. I don't need to access only one ingredient. That's a set. Sets are stored and accessed more efficiently than arrays or dictionaries. So if you can use a set, do so. Let's convert this struct to sets. For the two constants on…
Contents
-
-
-
(Locked)
Use Xcode Git repositories6m 59s
-
(Locked)
Read and write text files6m 47s
-
(Locked)
Prototyping MapKit in iPad Playgrounds8m 32s
-
(Locked)
Use the Xcode 9 simulators4m 24s
-
(Locked)
Layout and iPhone X5m 35s
-
(Locked)
Use markers instead of pins for map annotations4m 32s
-
(Locked)
Read JSON files7m 59s
-
(Locked)
Copy and paste with the pasteboard5m 25s
-
(Locked)
Create navigation controllers6m 39s
-
(Locked)
Make a camera on iPad7m 50s
-
(Locked)
Tricks with Asset Manager6m 40s
-
(Locked)
Array tricks10m 56s
-
(Locked)
Apple watch and the context menu6m 25s
-
(Locked)
Image and color literals6m 48s
-
(Locked)
Why use uint8?10m 14s
-
(Locked)
Using hex color9m 39s
-
(Locked)
Deep dive into dictionaries9m 11s
-
(Locked)
Tapping a map7m 3s
-
(Locked)
Update old apps3m 47s
-
(Locked)
Using Apple Pencil8m 42s
-
(Locked)
Animated emoji on the Apple Watch5m 46s
-
(Locked)
The navigation bar and back title4m 34s
-
(Locked)
Using property lists7m 44s
-
(Locked)
Using popovers8m 23s
-
(Locked)
Attributed string jazz9m 18s
-
(Locked)
3D text with SceneKit5m 54s
-
(Locked)
Find a language quickly from text8m 29s
-
(Locked)
UIColor class extensions5m 46s
-
(Locked)
Using Date and TimeInterval6m 5s
-
(Locked)
Time zones and date components7m 40s
-
(Locked)
Timer accuracy6m 25s
-
(Locked)
Animate maps5m 17s
-
(Locked)
Xcode 10 storyboard changes7m 46s
-
(Locked)
Use code snippets8m 40s
-
(Locked)
Changes to playgrounds in Xcode 106m 42s
-
(Locked)
Permission changes to notifications6m 45s
-
(Locked)
Customizing the tab bar8m 31s
-
(Locked)
The Settings bundle9m 26s
-
(Locked)
Use the speech synthesizer6m 45s
-
(Locked)
Make round buttons7m 45s
-
(Locked)
Recursion and changing UIViews7m 46s
-
(Locked)
Lay out iPad landscape and multitasking apps7m 52s
-
(Locked)
Embed table views6m 36s
-
(Locked)
Make a toggle button7m 37s
-
(Locked)
Drop shadows6m 24s
-
(Locked)
Blur and vibrancy effects8m 48s
-
(Locked)
Inequalities in Auto Layout for storyboards5m 52s
-
(Locked)
Make an animated settings drawer6m 57s
-
(Locked)
Views in playgrounds6m 52s
-
(Locked)
Launch the Settings app4m 45s
-
(Locked)
Draw paths in UIViews8m 4s
-
(Locked)
CALayer masks7m 14s
-
(Locked)
Protocols and time pickers6m 38s
-
(Locked)
Convert strings to time intervals11m 13s
-
(Locked)
Sliders as knobs7m 36s
-
(Locked)
Fix stackview disasters8m 9s
-
(Locked)
Using haptics4m 57s
-
(Locked)
Test flight9m 8s
-
(Locked)
Replacing segmented controls9m 50s
-
(Locked)
Ranges6m 48s
-
(Locked)
Unicode characters8m 36s
-
(Locked)
String and NSString characters8m 49s
-
(Locked)
Thrown errors9m 41s
-
(Locked)
Actions in table views7m 5s
-
(Locked)
Ducking sound in AVAudioSession4m 35s
-
(Locked)
Make and use closures7m 4s
-
(Locked)
Using ARC6m 20s
-
(Locked)
Create a project without a storyboard7m 29s
-
(Locked)
Learn how to rename identifiers3m 22s
-
(Locked)
Add a split-view controller programmatically7m 8s
-
(Locked)
Add dynamic type for accessibility6m 35s
-
(Locked)
Quickly identify a UIColor to RGB or HSB system6m 27s
-
(Locked)
Launch an alert from a closure and what to do about it5m 57s
-
(Locked)
Connect outlets and actions without the Assistant Editor8m 32s
-
(Locked)
Get BASIC with swift strings7m 56s
-
(Locked)
Convert CSV files10m 7s
-
(Locked)
Strings to doubles8m 14s
-
(Locked)
Enums13m 4s
-
(Locked)
Selection in text views5m 30s
-
(Locked)
Generate QR codes5m 13s
-
(Locked)
The ? and ?? operators in Swift5m 47s
-
(Locked)
String interpolation6m 59s
-
(Locked)
Xcode changes5m 52s
-
(Locked)
Use Dark Mode on storyboards4m 45s
-
(Locked)
Use SF Symbols8m 42s
-
(Locked)
Structs6m 18s
-
(Locked)
Quick SwiftUI8m 55s
-
(Locked)
Working with sets7m 28s
-
(Locked)
Segue Actions4m 38s
-
(Locked)
Checkboxes in SwiftUI6m 15s
-
(Locked)
To-do lists in SwiftUI4m 27s
-
(Locked)
Quick Help in SwiftUI6m 29s
-
(Locked)
Models in SwiftUI6m 38s
-
(Locked)
SwiftUI in Xcode Playgrounds6m 39s
-
(Locked)
Keyboard shortcuts for Xcode 114m 44s
-
(Locked)
Basic PencilKit5m 45s
-
(Locked)
Setter and Getters5m 15s
-
(Locked)
UITextViews and coordinators6m 22s
-
(Locked)
Dark Mode in code6m 1s
-
(Locked)
Candle effects7m 53s
-
(Locked)
Reality Composer7m
-
(Locked)
RealityKit5m 44s
-
(Locked)
NumberFormatter6m 7s
-
(Locked)
Tuples4m 42s
-
(Locked)
Protocols6m 16s
-
(Locked)
Property wrappers5m 19s
-
(Locked)
iPad to macOS6m 11s
-
(Locked)
Type properties5m 11s
-
(Locked)
Singletons and TabViewControllers4m 59s
-
(Locked)
UITabViewControllers in Swift Playgrounds4m 25s
-
(Locked)
Motion effects7m 27s
-
(Locked)
SwiftUI animation8m 24s
-
(Locked)
@Binding in public6m 38s
-
(Locked)
SwiftUI ScrollView5m 30s
-
(Locked)
MapKit points of interest6m 14s
-
(Locked)
UIKit extensions and pseudo SwiftUI6m 12s
-
(Locked)
SF Symbols configuration5m 44s
-
(Locked)
Custom SF Symbols8m 7s
-
(Locked)
Use SwiftUI GeometryReader4m 15s
-
(Locked)
Proportional SwiftUI views8m 22s
-
(Locked)
Button selection panels in SwiftUI5m 35s
-
(Locked)
Custom modifiers in SwiftUI6m 22s
-
(Locked)
Dependency injection6m 28s
-
(Locked)
Xcode themes7m 16s
-
(Locked)
Basic generics5m 58s
-
(Locked)
Selections in watchOS7m 23s
-
(Locked)
ForEach closures in SwiftUI6m 7s
-
(Locked)
SwiftUI borders and shapes8m 54s
-
(Locked)
SwiftUI gradients11m 13s
-
(Locked)
Special parameters8m 49s
-
(Locked)
Overriding operators8m 29s
-
(Locked)
Arrays with map, filter, and reduce7m 21s
-
(Locked)
Basic measurements9m 26s
-
(Locked)
Key paths7m 9s
-
(Locked)
Recursive structs8m 38s
-
(Locked)
Outline views in SwiftUI5m 42s
-
(Locked)
TextEditor and Scribble4m 51s
-
(Locked)
Color pickers8m 54s
-
(Locked)
Local notifications in SwiftUI8m 41s
-
(Locked)
Enums with values7m
-
(Locked)
Changes to enums in Swift6m 15s
-
(Locked)
SwiftUI transitions for modal views4m 55s
-
(Locked)
Date pickers6m 54s
-
(Locked)
SwiftUI labels3m 26s
-
(Locked)
SwiftUI maps6m 5s
-
(Locked)
Collection views for SwiftUI3m 50s
-
(Locked)
Scribble bugs4m 48s
-
(Locked)
The joys of UUID5m 8s
-
(Locked)
SwiftUI swipe gesture4m 2s
-
(Locked)
Holiday special: Let it snow6m 17s
-
(Locked)
Embed images in SwiftUI text5m 44s
-
(Locked)
Make a widget, part 1: Presenting9m 16s
-
(Locked)
Make a widget, part 2: Families8m 45s
-
(Locked)
Make a widget, part 3: Timelines8m 45s
-
(Locked)
UICollectionView lists11m 24s
-
(Locked)
UICollectionView layout9m 41s
-
(Locked)
Menus on UIButtons10m 27s
-
(Locked)
MatchedGeometryEffect modifier8m 50s
-
(Locked)
Multicolor symbols7m 33s
-
(Locked)
Multiplatform Swift UI8m 10s
-
(Locked)
Documents in SwiftUI8m 51s
-
(Locked)
Keyboard shortcut modifier7m 3s
-
(Locked)
Text, Dynamic Type, and accessibility7m 40s
-
(Locked)
Photos picker7m 51s
-
(Locked)
What is Hashable?6m 11s
-
(Locked)
Add stickers to your app8m 7s
-
(Locked)
iPad Playgrounds...for Mac?6m 14s
-
(Locked)
Lazy variables4m 15s
-
(Locked)
Core graphics in SwiftUI4m 59s
-
(Locked)
SwiftUI checkboxes9m 3s
-
(Locked)
Core Graphics datatypes10m 22s
-
(Locked)
Setup for UIKit Drawing8m 2s
-
(Locked)
Practical CGRects9m 44s
-
(Locked)
Paths and contexts in CoreGraphics7m 52s
-
(Locked)
Distance-based graphics in CoreGraphics6m 50s
-
(Locked)
Recursive graphics6m 17s
-
(Locked)
CoreGraphics curves7m 27s
-
(Locked)
SwftUI maps and map zoom9m 5s
-
(Locked)
Maps and auto zoom6m 29s
-
(Locked)
Add pages in SwiftUI4m 27s
-
(Locked)
Closures in structs5m 35s
-
(Locked)
Xcode 13 changes5m 22s
-
(Locked)
New UIButton tricks7m 11s
-
(Locked)
SwiftUI Changes for iOS 159m 41s
-
(Locked)
SF Symbols 37m 7s
-
(Locked)
Swfit UI binding in lists3m 46s
-
(Locked)
TimelineView8m 50s
-
(Locked)
SwiftUI image concurrency8m 44s
-
(Locked)
SwiftUI Playgrounds9m 11s
-
(Locked)
Custom widgets with intents, part 18m 3s
-
(Locked)
Custom widgets with intents, part 27m 55s
-
(Locked)
Custom widgets with intents, part 38m 2s
-
(Locked)
Color for accessibility6m 6s
-
(Locked)
UIStackView programmatically6m 14s
-
(Locked)
The new date formatter8m 5s
-
(Locked)
Number formatters8m 58s
-
(Locked)
Links in text4m 23s
-
(Locked)
Accessibility labels10m 25s
-
(Locked)
So long, and thanks for all the views!2m 31s
-
(Locked)