Assertions allow you to stop your app from running if a certain condition is not met. This is helpful for debugging code and finding the source of a problem. See how it works here.
- [Lecturer] With an assertion you can use a condition…to stop your code if there's a problem,…for example, if a variable is not within appropriate bounds.…Let's go into applicationDidFinishLaunching…and create a simple assertion here.…I'm going to define a number,…set it equal to 100.…On the next line I'm going to call…an assert statement, and what this is going to do…is it's going to create, as it says here,…"A traditional C-style assert with an optional message."…Let's do the one that has a message.…
So I'll press down on my keyboard…and Return to have Xcode complete that for me.…The condition is a Boolean value…so you want to have something in here that has to be true,…otherwise there's a problem.…For example, we can say that num constant…we created on the above line is supposed…to be 100 at all times.…So we can put something in like this,…num equal to 100.…If this condition is ever not true…the application is going to stop running…and give the following message.…
So I'll tab to the message parameter,…I'll type in, num is supposed to be 100.…
- Installing your development tools
- Working with Xcode and the MVC pattern
- Creating basic interactions
- Creating delegate classes
- Building a user interface
- Laying out the UI
- Working with data and table views
- Binding data objects to the UI
- Debugging your app
- Distributing the app
Skill Level Beginner
1. Get Started
2. Core Cocoa Skills
4. Create User Interfaces
5. Arrange User Interfaces
6. Use Data Controls
7. Debug and Troubleshoot
8. Distribute an Application
9. Finishing Touches
Create full screen apps1m 51s
Next steps1m 21s
- 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.