Every project is going to need source control, even if you are the only dev. The most common ones are Git and SVN.
SVN (Apache Subversion) is a software versioning and revision control system distributed as open source under the Apache License. It’s a central repository where working copies are generated and a network connection is required for access. Its access authorization is path based, it tracks changes by registering files and the change history can only be seen, fully, in the repository. Working copies only contain the newest version.
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git is easy to learn and has a tiny footprint with lightning fast performance. You will have a local repository on which you can work, with a network connection only required to synchronise. Its access authorization is for the entire directory, tracks changes by registering content and both the repository and working copies have the complete change history.
There is a wide array of patterns used in mobile app development, MVC, MVP, MVVM, VIPER, etc. I will give you a quick overview of the most commonly used in iOS development:
The Model-View-Controller (MVC) is an architectural pattern that separates an application into three main logical components: the model, the view, and the controller. Each of these components are built to handle specific development aspects of an application. MVC is one of the most frequently used industry-standard for create scalable and extensible projects. Downside to MVC would be testing. If you do tests, you will probably only test the Model, due to it being the only layer separate from the rest. The plus of using the MVC pattern is that it’s intuitive.
MVVM is proposed by John Gossman in 2005. The main purpose of the MVVM is to move the data state from the View to the ViewModel. The data flow in MVVM could be drawn as the following figure:
The ViewModel knows nothing of the View, which facilitates testing and bindings reduce a lot of code. It might not seem of much importance, but well structured and organised code can prevent a lot of headaches. A big mistake every developer commits at some point, is to just get to the desired result and forgo organising the code, under the illusion they are saving time.
In 2014, Apple launched Swift, a new programming language for iOS mobile apps that’s given iOS developers an alternative to Objective-C, an object-oriented superset of the C programming language that’s been the core of iOS development thus far. Swift is designed to be compatible with all of the existing iOS development tools—xCode, Objective-C, and the Cocoa framework—but its ease of use and improved features mean it’s quickly starting to replace Objective-C
Advantage of Objective-C:
Disadvantages of Objective-C:
Advantages of Swift:
Disadvantages of Swift:
Apple offers great interoperability between Objective-C and Swift, and is not dropping support for Objective-C anytime soon. It is better for teams to start migrating parts of their Objective-C code to Swift as it is ABI Stable now. If you are developing a binary framework I would suggest waiting for Swift to achieve Module Format Stability. Also, if you are dealing with C++ and Objective-C++ codebase or framework, then you would need a mix of Objective-C and Swift. The Objective-C part can interface directly with the C++ or Objective-C++ parts of your code and the Swift part can then use Objective-C classes to interact with the C++ or Objective-C++ code.
CocoaPods is the most common dependency manager for Swift and Objective-C Cocoa projects. They simplify the process of implementing a library and keeping it updated. CocoaPods has a truck load of libraries, is built with Ruby and can be installed using the following command:
$ sudo gem install cocoapods
After installing it, you will want to create a Podfile for your project. You can run the following command:
$ pod init
or create a custom Podfile with this structure:
platform :ios, '8.0'
use_frameworks!
target 'MyApp' do
pod 'AFNetworking', '~> 2.6'
pod 'ORStackView', '~> 3.0'
pod 'SwiftyJSON', '~> 2.3'
end
once created, it’s time to install your new pods:
$ pod install
Now you can open your project’s .xcworkspace and don’t forget to import your dependencies.
Lets start with a simple way of saving data for your apps. UserDefaults, called this way, because it’s generally used to save default user data, that is put in when the app is first loaded. For this reason it’s made to be simple and easy to use, however this implies some limitations. One of it’s limitations is the type of objects it accepts. It acts very much like a Property List (Plist), which also has the same limitation.
Keychain is a password management system and can contain passwords, certificates, private keys or private notes. The keychain has two levels of device encryption. The first level uses the lock screen passcode as the encryption key. The second level uses a key generated by and stored on the device.
CoreData is a framework designed by apple, for your application to communicate with it’s database in an object oriented manner. It simplifies the process, reducing the code and removing the need to test that section of code.
Realm is a fast, easy to use, and open source alternative to SQLite & Core Data. Build offline-first, reactive mobile experiences using simple data sync.
UITableView is one of the most important user interface components on iOS. UITableView display a list of items, in a single column, a vertical fashion, and limited to vertical scrolling only. Each item is represented by a UITableViewCell, that can be completely customized. These can be sorted into sections and rows.
UICollectionView, introduced in iOS 6, has become one of the most popular UI elements among iOS developers. What makes it so attractive is the separation between the data and presentation layers, which depends upon a separate object to handle the layout. The layout is then responsible for determining the placement and visual attributes of the views. UICollectionView also display a list of items, however, they can have multiple columns and rows (grid for example). They can scroll horizontally and/or vertically, and each item is represented by a UICollectionViewCell.
Storyboards allow a broader view of the project, which designers love, because they can see the app flow and all of the screens. The downside is that as more screens are added, the connections become more confusing and storyboard load time is increased. Merge conflict issues happen a lot more often, because the whole UI belongs to one file. They are also a lot more difficult to resolve. You can separate by different storyboards. Xibs provide a visual view of screens or portions of a screen. Their advantages are ease of reuse, less merge conflicts than the storyboard approach and an easy way to see what’s on each screen. Programming your UI gives you a lot of control over it, less merge conflicts and, if they do occur, are easy to solve. Downside is the lack of visual aid and extra time it will take to program.
A protocol defines a blueprint of methods, properties, and other requirements that suit a particular task or piece of functionality. The protocol can then be adopted by a class, structure, or enumeration to provide an actual implementation of those requirements. Any type that satisfies the requirements of a protocol is said to conform to that protocol. Protocols exist in our daily lives to make sure, in a given situation, we know how to react. For example, let’s say you are a fireman and an emergency situation arrises. Every fireman has to conform to the protocol that sets the requirements to successfully respond. The same applies to a Swift/Objective-C protocol. You define protocols in a very similar way to classes, structures, and enumerations:
protocol SomeProtocol {
// protocol definition goes here
}
Custom types state that they adopt a particular protocol by placing the protocol’s name after the type’s name, separated by a colon, as part of their definition. Multiple protocols can be listed, and are separated by commas:
struct SomeStructure: FirstProtocol, AnotherProtocol {
// structure definition goes here
}
If a class has a superclass, list the superclass name before any protocols it adopts, followed by a comma:
class SomeClass: SomeSuperclass, FirstProtocol, AnotherProtocol {
// class definition goes here
}
I’ll be focusing only Swift closures. They are mostly used to return a completion block or with high order functions. Completion blocks are used, as the name indicates, to run a block of code, after a task is finished. Closures in Swift are similar to blocks in C and Objective-C.
If you want to write a beautiful, maintainable and readable code you have to use design patterns. You should know what they are and use them appropriately. In iOS these are “must knows”:
First, you must know formats like json, xml, html. Then you should know how to make network requests, parse json data, chain asynchronous requests, make authentication and use tokens. You should also have an idea how to cache network requests.
Building great UI is very important in the iOS world. There are several things I would like to point out here: You should know how to build a user interface from interface builder and from a code. You should know the pros and cons of both and when to use one over another. You should have deep knowledge about auto layout and know when to use it and when not. You should know how to build an interface for different device sizes. You should know about the UI calculation on non-main thread.
Great UI comes with an animation. I will repeat again, great UI is very important in the iOS world. Sometimes it seems like the most important thing. To keep up, these are the required things to know: Basic animations on UIView Core animations Custom transitions between two screens (push, pop, present, dismiss)
Every day something new comes in the iOS industry and we can all agree that nobody can know everything. To keep up with all the new stuff, constant education is very important. That is why you should read books, blogs, watch videos, follow newsletters, attend meet-ups and conferences, generally speaking, be active in the iOS community. Furthermore, writing blogs/books, speaking at conferences or developing your own library is a big bonus.