Sometimes you want to create a user interface object using code instead of in a XIB file. This video shows how to create UI objects with code, and how to connect them to events.
- [Narrator] Let's say you wanted…to create some user interface elements with code.…You're going to head over to AppDelegate.swift,…and then hide the two areas on the left and the right,…and go into applicationDidFinishLaunching.…And here we're going to create a label.…So here, we simply define a label,…and we can set it equal to an NSTextField,…and then we can call the constructor.…And to create a label, all we need to do…is pass in the constructor for labelWithString.…
So, we call this method,…and then we pass in the string that we want…for our label.…Example label is fine.…Now, what we need to do is put this label…inside some sort of superview.…So, if we got to the next line,…we can type out window,…that's our main window for our application,…dot content view, if you look at the hint in here,…it says the window's content view,…the highest accessible NSView object…in the window's view hierarchy.…That's the same as that default view…that we put everything in,…when we use Interface Builder.…
And we tell the content view to add a subview,…
- 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.