Join Todd Perkins for an in-depth discussion in this video Using assertions, part of Cocoa with Swift Essential Training.
- View Offline
- Exercise Files
…Now we have already looked at break points and handling exceptions.…But what about if you want to cause your application to crash?…If for example, a variable is not within a certain range or if something is wrong.…Now the reason you might want to do that is so…that you can catch problems early on.…So another Debugging tool you have is called an Insertion.…So let's look at how they work in Cocoa.…So I have a Button on the screen and…it's connected to the make assertion method in AppDelegate.…
So let's go over to AppDelegate and make assertion is very simple.…MyNumber is equal to 100.…So let's say that no matter what I want this number to be equal to 100.…Now of course, that may not be your exact nee, obviously.…But we want to check to see if a certain value is true.…So let's go to the next line and we'll create an assert line of code.…So we start to type assert and…I want you to pick the one with the Boolean in the code hinting.…So I'll press Return and have Xcode type that out for me.…
Now the first parameter is a condition and the second is a message.…
- Creating your first Cocoa app
- Understanding the relationship between Cocoa and Swift
- Creating a playground
- Working with variables, functions, arrays, and loops
- Creating basic interactions and quick connections
- Building custom controller classes
- Using delegates
- Creating and arranging interface elements
- Using data controls
- Debugging and troubleshooting
- Distributing a Cocoa application
Skill Level Beginner
1. Getting Started
Installing the tools1m 14s
2. Introduction to Swift
3. Core Cocoa Skills
5. Creating User Interfaces
6. Arranging User Interfaces
7. Using Data Controls
8. Debugging and Troubleshooting
9. Distributing an Application
10. Finishing Touches
Creating full-screen apps4m 56s
Next steps1m 36s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.