What is Swift?
Swift is the modern language created by Apple which got the Apple developer world buzzing. While loved by iOS developers, Objective-C was at the same time seen by many others as an outmoded language – a verbose and peculiar syntax, and with an unsafe type system. Built as a modern alternative to Objective-C, Swift was designed with specific enhancements in mind, specifically safety, performance, and expressiveness.
- _Safety_ — Swift introduced several programming concepts to reduce some common programmer mistakes. These include strong typing, optionals and error handling.
- _Performance_ — Apple has introduced internal optimizations to ensure that Swift runs fast. Xcode also provides warnings to encourage you to write code that ensures your app is running optimally.
- _Expressiveness_ — Expressive code has the right balance between containing a clear meaning and being succinct.
Exploring iOS SDK
Your app will never directly access the hardware, instead of the iOS SDK provides abstraction layers for apps to access the underlying hardware, instead of the iOS SDK provides abstraction for apps to access the underlying hardware.
Exploring iOS SDK
Figure 1.1 shows the abstraction layers of the iOS SDK, from the higher services and features to the lowest level interfaces. Table 1.1 has more details about what is contained in each layer.
To access features in the iOS SDK in your code, you will need to import the appropriate framework. Some common frameworks available in each of the layers in listed in figure 1.1.
There are two very commonly used frameworks in iOS app development:
- UIKKit framework of theCocoa Touch layer — among many features provides the basic architecture of your app, a library of standardized views and controls, and manages user input. The UIKit is often imported by default, which in turn imports the Foundation framework by default.
- Foundation framework of the Core Services layer — provides additional features and functionality for basic data types. Foundation also adds some additional basic classes and utilities, such as URLs, timers, formatters and notifications.
Editing your app’s interface
Storyboards and nibs
Storyboards are used to visually define your app’s user interface and the flow of navigation within your app.
A related concept to the storyboard is the nib. A nib also represent a user interface in a visual way, but represents one scene or par of it.
View Controllers and Views
Everything that you see in your scene is a type of view (or is rendered within a view). Text fields, labels, buttons, switches and images are all examples of types of views.
Storyboards and nibs at their rawest are just XML files. Unlike HTML, iOS developers rarely work directly with these XML files, opting instead to use Interface Builder, a visual environment that Apple provides you for editing your storyboards and nibs.