
In this section, we will cover the following topics:
Hardware
Programming Languages
Different Software
Tool of Choice (XCode)
Use of iOS Simulator
Interface Builder
Developing a Very Basic App
Files In XCode
Some Basic Terminology
Using Text Views and Labels
Finally Getting Ready for Next Section
You would need to keep the following in mind regarding the hardware you’d need to be able to use this course:
You could use a Mac Machine or Laptop (potentially you can buy a mac mini)
Or you can install Mac Operating system on a Windows machine
You don’t need to have an iPhone device to actually use this course
Different software tools that one can use to develop an iOS app are also discussed. We briefly cover the advantages and disadvantages of each of them.
An important matter in here is learning that software alone is not enough. We would also need a programming language
A wide range of IDE software are used to develop iOS Applications. Some of them are as following:
XCode -> Apple default iOS IDE
Xamarin -> Microsoft cross platform (iOS, Android, Windows) IDE
PhoneGap -> HTML5 + Javascript iOS Development
Flutter -> Google’s new cross platform IDE
IDE stands for -> Integrated Development Environment
Next we opt for XCode as our primary development tool. It’s an IDE that offers a wide range of options and it’s best suited for native iOS development.
We will have to download a version from Apple Developer Website and install it on our computer
XCode is equipped with various tools and programming languages and will take care of the debugging and running the app.
The following two programming languages could be used to develop iOS apps in XCode:
Objective-C (older and yet quite useful)
Swift (more modern and most commonly used)
For a very crude presentation, we start a new project in XCode and get a sense of what the different settings mean.
We will also realize where are two programming languages are located and how we are going to use them throughout this course
It’s important to notice that at this point, you might not understand a lot of these things and that’s perfectly fine
Let’s have a look at some of the basics of XCode and try and understand how different things work together
XCode has 5 primary areas:
Text Editor
Toolbar
Utility Window
Navigation Window
Debugging Area
Interface Builder is used to design the visual elements of our iOS Apps
Having a look through how we make basic outlets and attributes editor of the interface builder. We will also look at the dimensions and get a starting sense of how the point system works.
In this lesson, we will make a Label that shows Hello World.
Simulator will compile our app. Compile is the process of converting your code and interface into an actual app. It is actually more advanced than this simple explanation, but this simple one will suffice for now. iOS Simulator is used to display the app in a device-like simulator. Simulators have both device and version. One could have different devices with different iOS versions. A simulator although very similar, it is not the exact as the phone device.
In this lesson, we'll get to simulate our app on different devices and different sizes. After trying different sizes, I suggested that you stick to only one as it will simplify your lives from now on.
In this lesson, we will also briefly touch on making a simulator a default one and also how to add or remove simulators.
What’s the relationship between all these different files in XCode. What are they and how do they work? What should we wok on and how should we get comfortable working on our project? And also which files can be ignored for now?
In this early stages, there are only ever 3 files that are important for iOS App development. Those files are:
.storyboard file -> which is your visual design file
.m file -> which is the actual programming file of your application
.h file -> Which is the header file containing the declaration that also works as the connection between the .m and the .storyboard file
Build ~ Run ~ Compile -> Is the process of converting the iOS project in XCode into an iOS App in Simulator (or a physical device)
In this lesson, we will talk about outlast and how we can connect them to our app. Remember, it is not important to completely understand what is happening as this is more of an illustration
For now you can just copy paste my code. Everything about properties, dot operation, cycles, etc. will come later
In this lesson, we will play around with a textview in our interface builder. Text view is a container where you can add larger text content.
In this exercise you are supposed to develop an app that has a label that shows hello world and a text views that shows your name and the city where you live in as well as some details about your city. Try and format your text.
Don’t worry if you don’t get what’s happening. We will talk about all of this soon
In this assignment you are supposed to develop an app interlace with 8 labels where all the gaps are the same.
Hint: Views have anchor points on their top left corner where the coordinates are x=0 and y=0. They then have width and height.
In this section we will go through the basics of programming in Objective-C. We will discuss some basic definitions such as:
Variables
dot operations
Collections
Functions
We will then learn how to call a function and how to use it. By the end of this section, you should have a better understanding of how a piece of code in Objective-c actually works.
For most everything in here, we will work outside of iOS and we will work on developing command line tools.
Command Line and Print
For practice purposes, we will rely on Command Line Tool projects from Mac OS templates. These are projects that can be utilized on Mac Terminal and act as command line tools. They compile a lot faster and help us speed up our learning process. We use
NSLog ( “” );
to print values into the XCode’s debugger console. NSLog prints whatever it finds within its two quotation marks identically to the console. We can format different value types to appear within NSLog.
Comments
Commenting is the process of leaving notes for yourself or your co-workers within the body of the code. This way you can write all of your learning in the program as well.
The compiler which is in charge of debugging and converting your code into an application (or a tool) will go through your program line by line. Whenever it encounters two forward slashes ( // ) or a forward slash followed by an asterisk ( /* ), the compiler will know to ignore that line (or lines) of code.
Basic Variables:
There are four basic variables that we covered in this lesson. These four are:
Int (used for whole number variables such as 5, -9, 10)
Float (used for numeric values with a decimal part such as 3.3, -9.8)
Bool (used for true, false status such as game being paused or downloaded being finished or not)
Char (used to demonstrate a single character such as ‘a’, ‘b’)
We can print different variables by formatting them correctly for NSLog. The simplest of conversion are as following
NSLog(@”%i”, 5); // used to print an integer
NSLog(@”%f”, 5.5); // used to print a float
For a complete list of all possible formatting, please refer to the following document:
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html
In this exercise, we have to find examples of things that are of the type char, int, float and bool.
Strings:
Strings are a series of characters joined with one another
We use strings for most of the text values
String is the default value that NSLog attempts to print
We can use methods such as stringWithFormat to format a variable or value into a string and to print them (or show them on a text enabled outlet)
Every variable has a declaration phase and a definition phase. Variables by nature have a changing status and their values change. That is the definition of them.
In declaring NSStrings unlike the previous variables, we use an asterisk. That is to make sure that the string is declared as a pointer. Pointers are really just an address for a space in memory and they are small pieces of data. If we had to store and copy the data being pointed to, we might very quickly run into problems of not having enough memory.
Appending Strings:
We can append two NSStrings by using the stringWithFormat
We could also append them by using stringByAppendingString
We could also use a mutable string:
Mutable strings are modifiable. We can change the content of the string without the need to re-write them again
In mutable strings we can benefit from appendString method
Like most everything else in Objective-C, we use the square brackets for calling a method such as
[myMutableString appendString: @”some new string”]
Variables in iOS:
Using variables in an iOS app is identical to that of a command line tool. Except when in iOS, we usually need to display our results in some sort of visual interface. In our example, we concatenated multiple variables by formatting them into strings and finally displayed them on a Text View.
If Else
Conditional statements are a part of control flow of every programming language.They work based on the following formula:
if ( condition)
{
In case it was true
}
else
{
In case it was false
}
We can nest multiple if statements within each other and we can also use “else if” as long as we know we are comparing the same condition.
For some variables such as integer, we can directly compare them using two equal signs ( == ). For others such as a NSString, we should use their built-in methods such as [myString isEqualTString: @”Some String”]
In numeric (and many other types) of comparison, we could use any of the following relational operators
<= (smaller or equal)
>= (larger or equal)
== (equal)
!= (not eqal)
&& (and)
|| (or)
! (not)
To learn more about conditional operators, you can refer to this tutorial: https://www.tutorialspoint.com/objective_c/objective_c_operators.htm
Operators:
There are four general types of operators that we discussed. These four are:
Arithmetic suc as: +, -, *, /, % (modulus or remainder of a division), ++, -- (increment by one and decrement by one)
Relational such as: ==, !=, >, <, >=, <=
Logical such as: &&, ||, !
Assignment such as : =, +=, -=, *=, /=, %=
There is also a precedence between different operators which means some of them get calculated before others.
To learn more about different operators, visit this tutorial:
https://www.tutorialspoint.com/objective_c/objective_c_operators.htm
We can use ternary if statement in Objective-C such as this:
(condition) ? (statement if true) : (statement otherwise)
Arrays and Sets:
Arrays and sets are used to contain objects (usually of the same nature) inside a container.
The advantage of an array is that it has an index that ordered objects for us. The index begins at 0 and counts upwards
To use NSArray, we need to both allocate and initialize it. We will talk much further about initializing in the future. Here is an example of NSArray
NSArray* myArr = [[NSArray alloc] initWithObjects: @"Monday", @"Tuesday", @"Wednesday", nil];
We can use count to get the number of elements in an array. We can access the different elements of an array using either objectAtInde or a subscript ( [] )
NSArrays are immutable so you can not add new objects to them. For adding or removing objects into an array, we use mutable arrays.
Sets are very similar to an array except that they don't have an order. As a result the objects in a set can not be duplicates and must unique. Here is an example
NSSet* mySet = [[NSSet alloc] initWithObjects:@"one", @"two", nil];
To find objects in a set we need to iterate through them. We will discuss these for loops in more details in the future.
You could also use the C arrays. These are arrays made of any kind of object such as int such as this:
int intArray[6] = {1, 2, 3, 4, 5, 6};
Objects in an array do NOT have to be of the same type.
This is the link to the apple documentation on collection. I suggest you skim through it real quick:
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Collections/Collections.html
Dictionaries
Dictionaries are a type of collection in Objective-C that have a key-value pairing between them.
As a result each value is paired to a certain key and can be searched and found using that key.
You can use the NSDictionary to initialize a dictionary such as:
NSDictionary *myDict = [NSDictionary dictionaryWithObject:@"value" forKey:@"key"];
You would most likely be using a NSMutableDictionary such as:
NSMutableDictionary *myMutDict = [NSMutableDictionary new];
[myMutDict setObject:@"Amir" forKey:@"Name"];
To access a value for a certain key, you would be doing:
[myMutDict objectForKey:@"Name"];
You could also initialize a dictionary with multiple keys and values at once like:
NSDictionary *multipleDict = [NSDictionary dictionaryWithObjectsAndKeys: @"Value 1",@"Key1",@"Value 2",@"Key2", nil];
It's worth noticing that the keys are arbitrary values and you can use whatever you like
We can get all the keys
[myMutDict allKeys];
And we could get all the values:
[myMutDict allvalues];
You can nest arrays and dictionaries within one another.
For Loops
We use for loops for repeating a task certain number of times.
There are two main for loop formats:
A for loop based on a number
for (int i = 1; i <= 10; i++)
A for loop based on an iteration of objects
for (NSString* currentString in myArr)
In a given array of the names of the cities, find out how many times, does the name “Vancouver” re-occur. There is a file asset for this exercise.
In this assignment, you are supposed to find the following:
Are the two arrays of the same size?
Are the objects the same?
Is the order of the objects the same?
And if the order is not the same, at what index the order breaks?
Switch
Switch is another control flow command that helps with organizing the code.
It enhances the readability of the code and also it is usually mode efficient than nested if else statements.
Switch is often used with a numeric value such as integer.
You could however try and implement switch with something like a string. Switch cases can be combined as well.
While
While and Do While are two other control flow commands.
They help with running a piece of code for as long as their express is still valid.
In While we first check for the correctness of the expression. In Do While, we first do something and then check for it.
Jump Statement
While running a loop, it is often required to jump out of the loop or perhaps break the cycle. Jump statements help us with that.
Functions
Functions are the operating parts of any object in a programming language.
An object might have some properties and some methods.
We use methods to better organize and partition our code.
Each method has a return type.
Every method may or may not have some input arguments.
Write an app that runs a Dice a million times and tells you how often different numbers show up.
Take a long string and break it into single words and find out how many of them are unique
Find out which of the users in the given array has more photos than others
Sort an Array of names to appear in a Alphabetical order
Sort a given array of dictionaries to be ordered based on whether the user is available or not
Basic User Interface
In this section, we will go back to iOS Development and using what we have learned in programming, we will begin working on a variety of basic user interface elements.
We will learn how to use UI elements as outlets and interact with them in our code. In specific in this section we will discuss topics such as:
GUI Kit
Buttons
Segmented controls
Image views
Text fields
UI switch
Sliders and steppers
View controllers
Navigation between view controllers
Passing data between different view controllers
By the end of this section, you should be easily add a variety of UI elements into your app and trigger functions in the code.
GUI Kit
In this lesson, we will have a look at the GUI Kit and try to familiarize ourselves with various available outlets.
These are the links to the two websites that we talked about in the video:
https://www.behance.net/gallery/54882503/iOS11-GUI-KIT
https://iosdesignkit.io/ios-gui/
Buttons
We use Buttons to trigger actions depending on when and where on them a click has landed.
We could call functions on actions directly using the assistant editor or we could use the View Controller's connection inspector to do that.
For calling actions, we could also use the addTarget method.
In this exercise, we will develop an app that when you tap a button, depending on a random generator, the name of one of the cities would appear on screen.
Scope of a variable
Variables also have a scope which means in which function (or functions) are they available.
If a declaration of a variables is inside a body of a function, that variables is said to be local to that function only.
If the declaration is outside, that variable is accessible by every function.
Segmented Controls
They work like radio buttons that only one of them can be active at any given time.
The event to trigger them is the Value Changed.
Their segments are ordered from 0 upwards.
Their segments can be removed dynamically.
Their segments can be inserted dynamically.
Similar to buttons, they can be called using addTarget.
Image Views
Image Views are the containers that can show us images.
Images can be read from a variety of sources. if we use an image that is embedded into our project, we can simply use the
[UIImage imageNamed: @""]
We will see other methods of converting NS Data into images in the future.
Load all images into an array and depending on the button that is pressed in segmentedControl, show one of them.
Text Fields:
In this lesson, we will learn to use basic text fields and decorate them.
We will also learn how to change the keyboard type on them and fetch values from them.
We will quickly discuss getting int values from strings as well.
We will also learn how to press a button to get rid of the keyboard.
Text Fields also have placeholders.
We should clear the text fields once they are used.
In this lesson, we will quickly cover the mechanics of using a UI Switch outlet and changing a value (string) based on that. We will also learn about casting the sender to UI Switch.
UI Sliders
Sliders are used to scrub between a minimum and maximum number.
Their default value is a float number.
You can set them to be triggered only when the scrub is finished and not a continuous trigger.
We will rebuild our image switch app to switch between the images using a slider. In this example, we have to make sure, we only get the integer values from the slider
To get integers, we could either cast our float value into integers or we could use ceil, floor or round.
UI Stepper
Stepper are used to increment a value.
Their step can be changed.
And they can step continuously or one at a time.
Steps don't have to be integers.
View Controllers
In this lesson, we will learn how to make a new view controller and how (from interface) go through a segue
View controllers are like a container that hold on to all UI objects for a certain class and they also provide user interactivity.
View Controller Class
In this lesson, we will learn how to add a new view controller class and connect it to our view controller in IB
We will run a test in which a value will appear from view did load
We will discuss both classes and run cycles of view controller in future
Segue
In this lesson, we will learn how to call a segue programmatically and in interface builder.
We will use the segues from buttons to view controllers.
We will also use segues from view controllers to view controllers.
We will talk further about the use of unwind segue. To use unwind segue, you would need a function with IBAction return type and an argument of the type UIStoryBoardSegue in the View Controller you are unwinding back to.
This part is a little confusing. Unwind segues are the only type of functions that you don’t code them in the class of your view controller. Rather you code them on where you want to go back to.
The difference between Unwinde and Pop is in sending data
Passing Data Between View Controllers
In this lesson, we will learn how to prepare for a segue and pass data between our different view controller
To do that, we need to prepare for an upcoming segue using the prepareForSegue built-in function
Recap
In this section, we covered the following topics:
Buttons and how to assign functions to them in the storyboard as well as using the addTarget.
Segmented controls and how their selectedIndex number helps us
Image Views and how we could load images into them and change the content mode.
Text Fields and how we could change keyboard on them.
Switch and how we could get their isOn state.
Sliders and how we could read their value.
Steppers and how we could use them to increment or decrement a value.
View controllers and how we could use them to categorize our app also assign separate view controller classes to them.
We finally touched on segues and passing data between view controllers using prepareForSegue
In this assignment, using the images and the dictionary provided, you have to write an app, where a user can enter name in the text field and if they exist in our “database”, their image should appear on the screen. Otherwise a warning should tell us that there is no such user.
In this assignment, you would write an app with two view controllers, in one of them we can enter details about a user such as their name, height, city where they live, etc. In the other view controller, we should be able to view the details of all of our users.
As a bonus, you can expand this app into making sure, we can search for a specific user by the name.
In this section, we talked about Swift and got started with actually coding in Swift. In particular we covered the following basic matters:
Swift Basics
Swift Playground
Swift Strings
Collections in Swift (Arrays and Dictionaries)
Functions in Swift
Playground is the learning environment of XCode for Swift. You could use it on both your Mac as well as on your iPad.
Next important topic is the variable in Swift. We have several different matters to keep in mind:
Let for introducing immutable variables. Let example is Objective-C is NSArray
Var for introducing mutable variables. Var example is Objective-C is NSMutableArray
Type Annotations
In Swift, we could use the type annotations to explicitly define the type of a variable.
Writing comments are similar to those in objective-C
Semicolons are not necessary in Swift.
String Interpolation print ("\(myFloat)")
Swift optional are a rather important topic. If a variable is optional, it can be nil. Otherwise it must have a value.
var optionalString: String? // which can be nil
var nonOptionalString: String = "Hello" // Which Must have a value
var unWrappedString: String! // implicitly unwrapped optional. Implicitly unwrapped optional are useful when an optional value is confirmed to exist. ! lets you treat the property as if it were non-optional
You can do force unwrapping by ! . It's not the safest thing to do though
var n : Int?
print ("\(n!)")
Conditional Unwrapping
var someVar : Int?
if let val = someVar // you can also use the same name
{
print ("\(val)")
}
else
{
print ("nada");
}
Type casting for unwrapping
var someVal: Any? = 1
if someVal as? String != nil {
print("This is string")
}
if someVal as? Int != nil {
print("Int's Int")
}
Link for further study: https://docs.swift.org/swift-book/LanguageGuide/OptionalChaining.html
If Else
In an If Statement, we don't need the round brackets, but the curly brackets for the statement are necessary
If n == true {
}
Switch
The break statement inside a switch can be used when you don't need a case to have any actual functionality.
for
In a for loop, you shouldn't use round brackets and the numbering is different. For in example
for any in "Ding"
{
print ("\(any)")
}
Repeat While and While are exactly identical to Do While and While
let someString = "Some string literal value"
let multilineString = """
These are the same.
"""
var variableString = "Horse"
variableString += " and carriage"
if quotation == sameQuotation {
print("These two strings are considered equal")
}
Read further at:
https://docs.swift.org/swift-book/LanguageGuide/StringsAndCharacters.html
Arrays in swift are rather simplified
var myArray : Array <String> = ["Hello", "World", "Swift", "iOS"]
print ("\(myArray)")
myArray.remove(at: 1)
print ("\(myArray)")
myArray.append("ObjC")
print ("\(myArray)")
You can use Any for arras where the type is not predetermined
var myArray : Array <String> = ["Hello", "World", "Swift", "iOS"]
if let index = myArray.index(of: "Hello") {
print("Found Hello at index \(index)")
}
You can still use the NSArray if you prefer, but you cannot explicitly select its type
var myNsArr : NSMutableArray = NSMutableArray.init(objects: "Hi", "World");
myNsArr.index(of: "Hi")
Dictionaries in Swift are rather simplified and powerful. We declare dictionaries by a var or let of the type dictionary and then we can explicitly mention the type of the values in that dictionary.
We could also let the types be inferred from the values.
Once we have a dictionary, we can add new key-value pairs to it or update them.
For iterating within a dictionary, we rely on tuples. Tuples are a powerful ordered set of values. The values can be accessed by index or by name.
var person = ("John", "Smith")
var firstName = person.0 // John
var lastName = person.1 // Smith
var person2 = (firstName: "John", lastName: "Smith")
var firstName = person2.firstName // John
var lastName = person.1 // Smith
var namesOfIntegers = [Int: String]()
namesOfIntegers[16] = "sixteen"
var airports: [String: String] = ["YYZ": "Toronto Pearson", "DUB": "Dublin"]
Or
var airports = ["YYZ": "Toronto Pearson", "DUB": "Dublin"]
airports["LHR"] = "London"
for (airportCode, airportName) in airports
{
print("\(airportCode): \(airportName)")
}
Swift functions are written in a slightly different format than that of Objective-C.
func myFunc (inp: String) -> (name: String, res: Int)
{
return ("Hello " + inp, 2)
}
myFunc (inp: "Amir")
We can also nest functions inside one another
func nestedFunc ()
{
func internalFunc () -> String
{
return "yo"
}
print ( internalFunc() )
}
nestedFunc()
From this point on, we should get used to both of them
In this lesson, we will go through a sample app in iOS with Swift.
We no longer have a .h and .m file. Everything is in one place
This app, will load a new random image based on the click of the button, It will not re-show any image. Only new unique ones. Once we expire all images, it’ll restart the images
In this assignment, you will re-write the User Manager app from the previous section. This time in Swift
More advanced topics in programming are perhaps one of our most difficult sections in this course primarily because it's a little dry. There are no actual apps in here, but we still need to learn all of these concepts very well. In doing so, we need to dive further into programming. And learn the following concepts:
Classes and Objects
Inheritance
Initialize (& de-initialize)
Protocols & Categories
Class Extensions
Class Methods
Properties
Closures (& Completion Blocks)
Type Casting
Timers
Getting Help
Selectors (& Class Type)
OOP
OOP is a fundamental concept. OOP is a programming paradigm that can be defined as contrast to other programming paradigms:
There are four main coding paradigms
Functional which view programs as mathematical formulas
Imperative that view a program as a series of instructions
Logical that is a model of information and the relationship between them
OOP where objects represent models and their interactions handles data.
In OOP, you have instructions that can build something. Those we call a class.
When we create an instance of that class, that we call an object.
Each class has a set of attributes and methods.
Attributes are things that a class has and subsequently their objects have.
Methods are functions that instances of a class can do.
Classes
The next thing we have to learn is how to use functions and attributes of a class in an object.
We first have to learn about initializing a class.
We should also know how to use classes within a same file or spread them in separate files.
Instantiate objects from a class is a process in which we make objects from our classes.
Classes in Objective-C
Similar to Swift, we can add classes in Objective-C which would require @interface and @implementation. We can then use these definitions to instantiate our objects.
Unlike swift, ObjC classes must have a base class. In the past, you have seen it when we used UIViewController Class and one of the most basic root classes is NSObject. Which is like a founding father of many classes. If you don’t know what base class you need, then you need NSObject.
In this exercise, you are asked to develop an array of users with classes and objects.
You should then be able to search for any user name and find their height.
We will do this is Swift
Each user must have at least the following attributes
Name
Last name
Height
Eye color
Active
In this assignment you need to take the code we wrote in the previous exercise and convert it to an Objective-C code
In classes, you can add multiple different inits. You can make them required or convenience
There is a default init() associated with all classes
Inits from super classes can also be overridden
If you have overridden an init, you can no longer use the init()
Swift automatically deallocates your instances when they are no longer needed
Optionally classes may have a deinit method for deinitialization
You could use the deinit method with no argument for some very specific purposes. For further learning please refer to:
https://docs.swift.org/swift-book/LanguageGuide/Initialization.html
And
https://docs.swift.org/swift-book/LanguageGuide/Deinitialization.html
Guard a programming structure to make sure some value actually exists. Guard in many ways is similar to an if let process. The only difference is that in guard, if the value (or values) that you want don’t exist, the function should return.
Convenience initializers are supporting initializers to create an instance of that class for a specific use case or input value type. We often use convenience inits when we want to populate the initial values of a an object using a set of values (mostly a dictionary)
Inheritance is about subclassing and overriding parent class methods and adding custom inits to the subclasses.
To override a characteristic that would otherwise be inherited, you prefix your overriding definition with the override keyword. Doing so clarifies that you intend to provide an override and have not provided a matching definition by mistake
Sub classes can have their own attributes and functions. They can also override base class’s functions
Further Reading: https://docs.swift.org/swift-book/LanguageGuide/Inheritance.html
Enumerations
Enumerations (or enums) are used to define a group of related values in a type-safe way.
The reason they are type-safe is simply because their values are constrained.
Please read more on Enumeration in: https://docs.swift.org/swift-book/LanguageGuide/Enumerations.html
Structures in Swift
Structs in Swift are very similar to that of Classes. The two big difference are:
Structs cannot have base class
Structs pass the value while classes pass the reference
As a result, classes are a lot larger and slower
As a rule of thumb, if you can get away with structs, use them, if not, use a class
In objective-C we use respondsToSelector: to determine at runtime if an object knows how to handle a given message.
We will also use the isKindOfClass in Objectice-C to learn about the type of an object.
In this assignment, you are asked to develop the same app as in our previous lesson in Swift. For the Object Type, you have to try and remember something we have already used before.
A protocol as the name implies is the blueprint of methods, properties, and other requirements that handle a certain task. They are then adopted by class, structure, or enumeration to do the actual work.
Unlike objective-C, swift doesn’t have optional functions in a protocol. If you need an optional function, you must leave its body empty.
Protocol only specifies the required property name and type. Not whether it should be stored or computed.
Protocols contain no logic. They are simply definitions of methods, no implementations
Reading: https://docs.swift.org/swift-book/LanguageGuide/Protocols.html
Delegation is a very commonly used pattern in iOS development. The delegate design pattern is a pattern that uses protocols. Delegation is when an object delegates some of its behavior or control to another object using a protocol and it is often used when an object needs to communicate information or request information from another object.
In this exercise, you will implement a protocol in an Actual App.
In this exercise, you will implement a protocol in Objective-C
In setting delegations for outlets, you could either add them by code using the .delegate, or in the storyboard by dragging over the view controller outlet. A text field for instance has many different delegates. It means many different protocols are being conformed in it.
In this assignment, you are asked to develop the same app as in our previous exercise in objective-c
Categories
This is specific to Objective-C
We will talk about the private categories in View Controllers used to declare private properties and methods. These are not exposed to any class outside this one.
Categories are used when you want to add methods to classes. We use them for mathematical stuff or when we need new functionalities
A question to ask yourself might be what is the difference between a category and a subclass?
We use class extension for breaking our code into so many pieces and modularizing it. These extensions in swift are the same as categories in Objective-C. In a real development in swift we depend heavily on class extensions.
Further Reading: https://docs.swift.org/swift-book/LanguageGuide/Extensions.html
Class methods are used to enact a function directly from a class and not an instanced object of it. Class and Static keywords have similar roles. Both the static and class keywords allow us to attach variables to a class rather than to instances of a class.
Where static and class differ is how they support inheritance: When you make a static property it becomes owned by the class and cannot be changed by subclasses, whereas when you use class it may be overridden if needed.
You can read further about this on: https://www.hackingwithswift.com/example-code/language/whats-the-difference-between-a-static-variable-and-a-class-variable
Reference Counting
Understanding various property attributes such as weak, retain is an important aspect of reference counting and memory management for iOS.
ARC is XCode way’s of memory management. It basically means when would the memory free up of an object.
All variables are strong by default. We use a weak reference whenever it is valid for that reference to become nil at some point during its lifetime. Conversely, use an unowned reference when you know that the reference will never be nil once it has been set during initialisation. You can read further about unowned references in this link:
https://agostini.tech/2017/07/23/memory-management-in-swift-the-strong-the-weak-and-the-unowned/
Here is also a little comparison of all variable property attributes:
weak - it says "keep this as long as someone else points to it strongly
atomic - multi threaded. Locks the value before any changes. so it turns something, even though it may not be correct
nonatomic - a single thread. Doesn’t lock the value, it clears it in the process of adding a new one. As a result, you might get nil
Retain is a pointer to an object. The setter will add a retain count to the object
Assign: When calling the getter of an assign property, it returns a reference to the actual data.
To read on this important topics, please visit:
https://stackoverflow.com/questions/8927727/objective-c-arc-strong-vs-retain-and-weak-vs-assign
We use the built-in Timer class to count time in a variety of formats.
Closure are important elements of swift programming. They help with dynamic variables as well as completion blocks (using Escaping Closures)
Closures in Swift are similar to blocks in C and Objective-C and to lambdas in other programming languages
Closures are self-contained blocks of functionality that can be passed around and used in your code.
Closures are particularly useful when you work with functions or methods that take functions as one or more of their arguments
You can read further about closures in: https://docs.swift.org/swift-book/LanguageGuide/Closures.html
In this lesson, we will look at ways for asking for help in various existing channels such as
Docs
Header Files
Stack Over Flow
In this lesson, you will develop a vehicle shop app.
An app that manages 3 different types of vehicles in a shop.
All vehicles share some characteristics
each category has its own specific stuff as well
We need some dummy data to produce at least the first 10 vehicles in different categories
Have the class of the vehicle initialize from both init and a convenience init
Use an enum for something in the classes
Use a separate view controller to add a new item
Pass the new item back using a delegate
Recognize when the done button on the text field is pressed
Make sure all 3 types conform to the certain protocol
Use class methods to produce dummies
User class extensions to clean everything up
When running a search, make sure you test for class type of objects in the array.
The results of the search should be displayed in a different view controller if the search item exists.
We should be able to search with name, brand, type and model
In this lesson, you will re-do the vehicle shop app but this time in Objective-C
Double are similar to floats with more precision.
NSNumber and its super class NSValue are container objects for keeping numeric (or otherwise) values.
We can use keywords such as the following to set regions in our code
Pragma Mark (obc)
MARK
TODO
FIXME
In intermediate user interfaces, you have to learn matters such as the use of delegations, frame size, autolayout and constraints.
We use the info plist file as a property list to entail the details about our app. You can read further about info plist at:
https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW1
View controller life cycle is an important aspect of an app. In learning that we should look into matters such as layoutIfNeeded and setNeedsDisplay.
In discussing a view controller life cycle the following functions are most important:
viewDidLoad: View is now created. Initialize your objects.
viewWillAppear: It runs every time the view appears. Don't run codes that shouldn't be repeated
viewDidLayoutSubviews: When the sub views are properly laid out
viewWillAppear: when the view has been laid out and is visible to user. good place to run animation, etc
viewDidAppear: ofen happening before the transition to another view controller
viewDidDisappear: when the view controller is no longer visible. useful to stop any continuously running tasks
didReceiveMemoryWarning: gets notified when you used up the available memory. You can use the built-in simulator feature to simulate a memory warning
We can user a progress view to demonstrate the progress of an event.
For real life applications, we do the progress increment using a real metric such as the downloaded amount. We could also simulate that using a Timer.
In this exercise, we will learn how to make sure only certain characters are being entered in a text view
Using Autolayout is an important aspect of iOS development. Auto layout helps with views that operate in both portrait and landscape mods. It is also useful for when different devices want to use the same app.
We should also learn about intrinsic values and learn how to specifically choose what size our different outlets have to be. You can add or clear all constraints in a view using the buttons at the bottom of the screen.
In this exercise, you will divide a ui view controller into a grid of 4x4 tiles.
One tile will be a simple labels.
Another tile will be split vertically between a label and button
Another tile will be split 1 to 2o between a UIImage and a Button
Last tile will be a card with an image background and button
Hard coding an outlet is an essential skills. You should know how to use a combination of Init, Frame, CGRect, CGPoint and CGSize for a variety of situations to develop outlets programmatically.
In this exercise, we will design 10 buttons on the screen divided equally.
Autolayout constraints can also be added programatically. These are useful when a group of outlets are to be created dunamically.
As per Apple’s own documentation, we should try and use stack views for any situation where similar outlets are placed next to each other.
In this exercise, we will design an interface for an app login view. Entirely in the Interface Builder.
In this assignment, you have to develop the interface for a profile view of an application.
We use touches and gestures to produce a variety of user interactions with almost any kind of outlet. They help us with matters such detecting a tap on an item or when we pinch two taps and want to rotate an object.
Touches began and ended are the most basic touch events. We use them to trigger the moment any number of touches have landed or left the screen.
Touches moved method is the next in line of the touches actions. Similar to both touches began and ended, it returns both the current location and the previous location of the touch in the view.
We use function overloads to call the same method but with different parameters or arguments.
Function overloads helps us add functionality to our code based on what we expect to write in the code. Read more on function overloads in:
https://www.programiz.com/swift-programming/function-overloading
In this exercise, you are asked to write an app that illustrates how many taps you can make in a certain given time.
We use UI Gesture Recognizer in the interface builder to add gestures such as pan, long press or pinch to our views.
Gestures can be used either as a point to return a value such as the amount of rotation or to trigger a segue
We can add gesture recognizer in both the interface builder and the code.
In order to add Gesture Recognizers in the code, we have to add them to a view. To use a GestureRecognizer we should sub-class it.
CG Transforms are a part of core graphics that help us translate, scale, rotate or skew an outlet.
In this exercise, we will learn how to use the various gestures to rotate and scale a ui image view
In this exercise, we will learn how to use a combination of touches moved and CG Transforms To pinch rotate and scale an outlets.
In this assignment, you are supposed to program a custom gesture recognizer that understands when two taps on the screen are moving on a clockwise or counterclockwise directions.
There are a wide range of Graphics and Animation frameworks in iOS. We should learn how to use view animation, animation blocks, transitions and core graphics and core animation.
There are two primary methods of animation in iOS using an animation and also a block animation. We can animate different properties of view and we can also use animation pause, repeat and re-play.
In using an animation block we can either have the completion block or just focus on the animation. The different UIView properties that are animatable are:
alpha
backgroundColor
bounds
center
contentStretch
frame
transform
In this exercise,, you are asked to develop an animation for an object that crosses the video horizontally and as it disappears from one side, it begins to appears from other.
In this exercise, you are asked to develop a custom UI View Controller transition between two View Controllers
Spring animations are useful for basic physical animations where the value bounces off it final destination of an animation.
We use UI Kit transitions to produce interesting transition effects between different objects, or views in iOS.
Core graphics is a framework that helps us in developing a variety of graphical items such as circle, lines, rectangles, etc.
A major drawing feature of core graphics is the use of bezier paths. There are different types of bezier paths.
A bezier path curved type which is a part of core graphics helps drawing curved lines.
In this assignment, you are supposed to develop a basic app that allows you to draw on screen.
We use CA Layer to add effects such as:
Drop shadows, rounded corners, and colored borders
Image 3D transforms and positioning
Image Non Rectangular bounds
Image Alpha masking of content
Image Multistep, nonlinear animations
The background Image (through a CGImage in CALayer’s content)
IBDesignable and IBInspectable are used to provide visual feedback of the CALayer feature in the interface builder.
In this exercise, you are asked to develop a UI View with a controllable gradient in interface builder.
Core animation offers more advanced animation control features such as such as animation pause or resume.
Beyond the basic Core Animation feature, you can use core animation keyframes to allocate different keyframes of an animation in different time spaces.
In this exercise, we will learn to develop an app where users can draw a path for an animation and the object would follow that path.
CA Transactions are useful to atomically combine multiple core animations or CA animations with UI View animations.
We can use the animation features in the autolayout as well. To do so, we have to keep the following in mind:
If you're setting a frame, Don't use auto layout
If you're using auto layout, Don't set a frame
Animate the constraint directly,
Change the constraints and animate that change
Use a transform
We use UI Dynamics to produce some basic physics. For better performing physics and for games, we will rely on sprite kit or scene kit.
In this real app development, we will work on developing an iOS memory puzzle game. In doing that, I will rely on techniques that are essential to ui design as well a correct programming exercise.
In this first lesson, we will start a new app for iPad and run it on simulator.
In this lesson, we will add the necessary items for our interface items. Keep in mind that some of these items will be removed later on. We need a game background, a timer label, a reset button. A game mode uiSegmentedControler and a Game win in Time Label. We would also need a label that illustrates the current game mode. Game mode should be hidden when the game is in playback mode.
In this lesson, we will change the proportions of some of our interface outlets and use constraints to properly adjust them to our views.
In this lesson, we will remove some of the items in our interface builder and begin designing them in our code. We will write the first for loop for doing so. Keep in mind some things will change later on.
In this section, we will write the second for-loop to complete our tiles for a 4 by 4 grid of tiles.
In this lesson, we will sub class a label class to be able to include some extra details. Keep in mind, this is useful for when we do things such as Image Views.
In this lesson, we will store all of our tiles and centers within an array.
In this lesson, we will learn how to Randomize our tiles using a randomized method.
In this lesson, we will program our timer method to count up as the game progresses
In this lesson, I will quickly partition the code into several files in order to enhance the code readability.
In this lesson, we will connect our Reset button to reset the timer value as well as re-randomize all the tiles. We will also add a new method that will hide all the tiles at this point
In this lesson, we will implement the touch ended event to detect the touches that land on our tiles.
In this assignment, you are asked to replace the touched ended method with a UI Tap Gesture Recognizer.
In this lesson, we will learn to call a new method that flips the tile that we have touched. Once we did that, we will go back to our reset function and flip all tiles back. We will flip them manually. We will use the flip to Hide function later on
In this lesson, we will prepare our code to compare the two tiles that we have tapped on.
In this lesson, we will learn how to flip a tile back if they are not the ones we were looking for or flip them forth if they are the ones that matched.
In this lesson, we will learn how to detect if the game has successfully finished.
In this lesson, I will illustrate an issue that we are facing and show you a solution around it.
In this lesson, we will program the game mode Segmented Control
In this lesson, we will learn how to use images instead of Labels for our game
In this lesson, we will program the game mode Segmented Control
In this section, we will add a new feature so player can choose whether they wish to play the Image Puzzle or Text Puzzle. We will finally clean the code as well.
Scroll views are a fundamental aspect of using iOS. They enable many of the other outlets such as Table View or Collection Views.
Scroll views are a major UIKit component.
You would usually want to have a content view within the body of your scrollview which contain all your objects.
You can simply add constraints (4 corners + w & h) in the add constraint window
In a scroll view, if you do not use auto layout to infer the content size values, you could produce the content size values using an actual content size.
Content insets solve the problem of having content that goes underneath other parts of the User Interface and yet still remains reachable using scroll bars. In other words, the purpose of the Content Inset is to make the interaction area smaller than its actual area.
Scroll View have a multitude of delegation methods such didEndScrolling or scrollViewDidScroll.
In zooming a scroll view, the important thing to remember is that the zoom happens on a content piece from the scroll view.
Content view for zooming should be a sub view of the scroll view itself.
You have to set the minimum and maximum of zoom.
Paging is a an interesting and yet simple feature of scroll views. It allows for scrolling an entire page of the scroll view.
We use page controls to display a number of page content in outlets such as scroll views.
In this exercise, we will learn how to connect a UI Page controller to a scroll view.
Re-useablity of UI Views is an important aspect of any good design. Among many methods for re-using a view, adding an XIB and loading it as a nib is only one of the many solutions.
Custom XIBs do not have to adhere to the same size of the main screen. They can be longer, wider or shorter.
In this exercise, we will develop an app that fits a set of images into images views and attaches them to a scroll view
Assuming a limited number of items such as the ones in the previous lesson, re-build the project using entirely the Storyboard outlets
Hi and welcome to the Complete iOS Development Bootcamp. This course is designed to be a one-stop shop for you to become an iOS developer. In designing this course I had the following matters in mind:
Covering the most up-to-date technology and methods.
Delivering everything that you need to know to develop advanced iOS applications ready for the market.
Instilling the attitude of problem-solving and making sure you know how to find your way on your own by the end of the course.
Covering almost all programming libraries related to iOS.
Providing numerous online and offline content to support your learning journey.
Providing tens of exercises and assignments to ensure you have enough practice.
Constantly updating the course based on students’ feedback.
Introducing all the best techniques of real developments.
Moving forward in the course and content complexity in a gradual manner that doesn’t overwhelm new programmers.
In developing this course I not only considered the beginner developers but also attempted to prepare it for those with intermediate iOS understanding or veteran programmers from other disciplines. In doing that, the course has been heavily subdivided. If you are totally new, it makes sense that you through the course lessons by lesson, but f you are already a programmer you can pick and choose on your own. hroughout this course, I covered a lot of different technologies and topics including but not limited to:
The very basics of developing an app
Use of XCode and customizing it
iOS Simulator
Basics to Advanced programming exercises
Basics to advanced user interface designs
Swift programming language at the depth
Handling touches and gestures
Use of graphics & Animations
Table views and Collection views
Version control
Device hardware features
Media
Networking
Maps and geolocation
Persistent data, Core Data & Realm
Accessing Web content
Notification
Sprite kit and 2D games
Scene kit and 3D games
Metal kit and low-level GPU
Augmented Reality Kit
Machine Learning Kit
Testing & Debugging
App store and Submissions
Throughout the course, I attempt to bring some of the best experiences I have gathered from years of teaching students to make sure you learn in the most efficient and the most useful way. In doing that I benefit from lessons, exercises, assignments, quizzes and external resources. I also stay available if you face any challenges and also constantly update the course content or add new ones depending on the feedback from students.
Prerequisites to join this course:
Basic understanding of how computers work.
Access to Internet
You would need a MAC OS Enabled computer. i.e. Mac, MacBook, MacBook Pro. iMac, etc.
Free IDE that you'll get from Apple's Website (XCode)
All programming and development matters will be covered in the course.
Preparation for loads and loads of new information
By the end of the course
Make real-life iOS Applications using advanced and relevant technology.
Be prepared to take on any iOS development challenges on your own.
Create various iOS applications with advanced User Interfaces, graphics, and animations as well as proper backend and data persistency.
Develop both 2D and 3D games (within iOS and XCode limitations)
Be prepared for iOS jobs and technical interview questions.
Write complex Swift code
Write complex Objective-c Code
Know how to convert Swift and Objective-C code into each other
Be familiar with loads of external libraries
Have hundreds of tiny apps at your disposal to develop larger scale applications
Develop market-ready apps for the industry.
Use Google technologies such as Firebase and Google Maps
Learn how to use Mac Command Line
Know how to use Cocopods to search and implement a variety of libraries and frameworks
Create your own iOS frameworks
Who is the target audience?
Anyone interested in developing iPhone / iPad apps (with or without any programming skills)
Experienced programmers who want to begin iOS development real quick.
Anyone who wants to focus on the programming side of iOS development.