Section 1

Preview this deck

What does the iOS application lifecycle consist of?

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

1

All-time users

1

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (126)

Section 1

(50 cards)

What does the iOS application lifecycle consist of?

Front

The main point of entry to our apps is the UIApplicationDelegate, a protocol we conform to, to do thing. A number of methods are called... applicationWillLaunch, applicationDidLaunch, applicationWillEnterForeground, applicationDidEnterForeground, becomeActive Will launch is called first and provides storyboards, then didlaunch allows for updates after state restoration. Foreground methods are called next, and also after interruptions to the app such as phone calls. ResignActive is called when home button pressed or a phone call happens for example, DidEnterBackground is called when app is backgrounded, it gives a few seconds to do any clean up WillTerminate is called when app will be purged from memory. Launching options can tell you about push notifications or urls that directed to the app.

Back

What is UserDefaults and when is it used?

Front

UserDefaults is a simple key value store that is persistent. It is not secure and not persisted through app installs. Generally it is used to store simple user preferences and configs.

Back

How do you download a file in swift?

Front

Typically use the download task function on URLSession. This will download a file and store in a temporary file in your app. The completion handler will give you a url to the temp file. You must open the file or move it to permanent disk storage to keep it. Otherwise completion handler will get rid of it.

Back

What options do you have with animation on iOS?

Front

UIKit - gives some basic animations on UIView, using .animateWithDuration methods. You can animate frame, alpha, background color changes for example. CoreAnimation - manipulate the layers of view using things like CABasicAnimation to animate border transitions for example. UIKit Dynamics - used for more complex animations that a user could interact with potentially

Back

How do you serialise and map JSON from the backend?

Front

Apple introduced Codable protocols that allow us to fairly easily encode and decode to and from JSON. If we create a Struct that conforms to Decodable and who's parameters match the JSON's types and variables names, we can use a JSONDecoder to decode directly to that struct. We can also provide explicit codingkeys to change the JSON variable names to names we may prefer. We can also use the init with decoder to decode JSON into different or custom types. Alternatively, what we often see is a ResponseModel that matches the JSON and a domain model object that the responsemodel is mapped to. This gives clarity between the actual response and the mapped data we require.

Back

What is KVO - Key Value Observation?

Front

KVO provides mechanics for observing property changes. It allows many observers to subscribe to one emitter. KVO in Swift requires dynamic @objc on variables and @objc on class to work as it uses Objective-C under the hood. The notification center uses a similar architecture to KVO to allow observers to subscribe to `post` notifications. You should remember to remove subscribers when they are no longer required. KVO is used in Reactive frameworks such as RxSwift.

Back

How do you typically implement networking in iOS?

Front

If you think of an iOS architecture as a layered system, then networking sits on the Service Layer, so it should be seperate from the UI, business logic or storage layers. A basic implementation for networking would be to have a NetworkManager wrapping a URLSession or an open source network manager. An API Client who uses the NetworkManager to send requests to an API and handles things like user authentication and signing requests. And then individual services responsiblef for defining what Endpoints to hit and what models to return. A UserService or a PostService for example. This gives a good level of seperation of concerns such that if a change occured in the APIClient are it would not impact the other areas.

Back

How do you save data to disk on iOS?

Front

Typically you use the FileManager, which can create subdirectories and store large files to disk. You can store any object so lonage as it is serialiable.

Back

What should go into the networking / service layer?

Front

Service Layer is between your app and any external data that you require. So things in the service layer may be responsible for communicating with network, over bluetooth, GPS, gyroscope etc. For any given service you'd ideally create a layered interaction where the low-level implementation details are hidden behind high-level interfaces. For example, a network manager may use URL Session, an api client may use that network manager and post service may use the api client. Or a BLEClient may manager connection to bluetooth devices, a PeripheralClient may manage discover, then a DeviceService may manage discovery, connection and communication to a specific device, and finally a certain data service will use that DeviceService and map it to models used in the app. These designs seperate concerns and provide layers of indirection.

Back

What are xibs and nibs?

Front

Xibs are interface builder files that define UI, when compiled they become nibs. For the most part they've been replaced by storyboards.

Back

Can a static library (.a) contain resources like images, sound files etc?

Front

No, .a files just contain compiled code from the archive utility. Instead you can create a .framework bundle that can also contain resources.

Back

Have you used sockets and/or pubsub systems?

Front

Sockets and pub/sub systems are used for near real-time connection. By opening a connection to a socket or subscribing to a publisher you get the most recent changes emitted from the publisher and any new published data. There are libraries out there that do the heavy lifting, such as Starscream With starcream you open the connection to a web socket, then use delegate methods to react to the output and connection states

Back

How can you unwrap an optional in swift?

Front

Force unwrap using the `bang` operator. This will crash if the optional is nil. You can use this for implicit unwrapping too, so you can tell the compiler I know this will exist, then refer to it as a non-optional later, as with IBOutlets to labels for example. Optional binding / unwrapping using if let or guard let to check if the value exists and do something else if it does not. Optional chaining, it certain cases you can refer to methods or properties in an optional and if it is nil it will act as nil.

Back

What is VIPER?

Front

VIPER is an architecture for building apps based on Clean Architecture. It focusing on seperating responsibilities. It is an alternative MVC and MVVM. In VIPER you have a View, Interactor, Presenter, Entity and Router. Each feature tends to be built around a Use Case and each Use Case fits into these building blocks. The basic flow of VIPER is a user is brought to a View from a Router. The View displays and receives User Input. The Presenter translates this User Input and tells the Interactor. The Interactor tends to contain the business logic and the Entities. It tells manages updates to Entities and tells the Presenter what to do next. Who in turns tells the View or the Router. Benefits: easier to test, Clean, SRP, good for big teams. Negatives: lots of boilerplate (code generation used), higher learning curve, need full buy-in and to stick tightly to it.

Back

What is the storage layer in an iOS application?

Front

The storage layer contains the classes responsible for saving, loading and persisting data in your app. This may be in-memory classes, UserDefaults, FileManager stores or databases like CoreData or Realm. A typical set of classes may be wrappers for Keychain, UserDefaults, FileManager as well as a Repository that reads and writes to disk. There are also NSManagedObjects that persist domain models to CoreData.

Back

What are Singletons? What are they used for?

Front

Singleton is a class that returns only one instance of itself, no matter how many times requested. Example - UIApplication.shared. Singletons are often thought as an anti-pattern. They store global state that may be changed somewhere in the app unexpectedly resulting in unexpected changes elsewhere. They are difficult to test as you cannot inject an alternative singleton unless you wrap your singleton in a protocol. Sometimes they can be useful, such as UIApplication.shared or Configuration.shared, when it is not likely to change.

Back

How do you work with UICollectionView?

Front

UICollectionView works very similarly to UITableView. It also requires a UICollectionViewLayout - and this defines the layout such as horizontal or vertical scrolling, differing cells sizes and heights. etc.

Back

What are extensions and categories in Swift and Objective-C?

Front

They are both ways of extending functionality. In Swift, extensions allow you to declare additional properties (not stored) and methods to a class or struct. They can be used to add conformance to protocols. In Objective-C categories are typically used to extend functionality of 3rd Party or Apple frameworks. A drawback is that extensions are globally applied by default so a declaration in one place is available everywhere, unless made private or fileprivate.

Back

What are the advantages and disadvantages of creating AutoLayouts in code versus using storyboards?

Front

Advantages of Storyboards: Quicker to build initial UI, can be easy to visualise, Apple provides many examples Disadvantages of Storyboards: Harder to debug, merge conflicts are more difficult to handle Advantages of Code: Explicit, easier to debug, possible merge conflicts are more clear Disdvantages of Code: Must compile app to see changes, constraint api can be challenging, SnapKit can help.

Back

Compare GCD and OperationQueues?

Front

GCD is an Apple API that allows you to dispatch blocks of code to be executed on different disptach queues, which can be serial queues or concurrent queues, and can be synchronous or asynchronous. GCD then handles thread management for you, you just know you're block will be executed at some point. OperationQueues are similar in that you can specificy Operations to happen on given queues. OperationQueues and Operations give you more control over your processing. You can set the priority of operations, check the status of existing operations, cancel operations and specify operation dependencies.

Back

How is memory management handled in iOS?

Front

Using Automatic Reference Counting. When an instance of a class references another instance, it increases that instances reference count by 1. As long as an instances reference count is more than 0 it remains in memory. When it becomes 0 it is deallocated memory. By default references between classes a strong. Value types (structs) do not increase reference counts as they are copied rather than referenced. Memory leaks can occur due to Strong Reference Cycles. For example, a UIViewController references a ViewModel. The VC passes a closure to the ViewModel referencing itself. Now we have a strong reference cyle that will prevent deallocation. Appending weak or unowned fixes this. Weak creates a weak reference that does not increase reference count and can be nil. Unowned explicitly states self will exist when this closure calls. Weak is used more often but unowned may be used for example, when you know a UIButton tap's closure will call the parent UIViewController.

Back

What are the concerns and limitations of networking on iOS?

Front

Battery and Bandwidth. Try issue as few requests as possible and retry if network suddenly drops. Large downloads and uploads should warn user. iOS 13 allows for scheduling background network tasks for times of high battery and good connection. We can also ensure wi-fi is used over network for big uploads downloads.

Back

What is URLSession and how does it work?

Front

URLSession is Apples API for networking. You can create URLSessions and configure them or use the default URLSession.shared. (A browser might use multiple sessions for example) Configuration can include cookie and caching setting, and even mocking. Within a session you can create multiple dataTasks, downloadTasks or uploadTasks. You can pause, start and cancel them. You can use a delegate to get updates on your session, or you can use a completion to handle a completed task.

Back

How do you handle multi-threading with networking iOS?

Front

You should not block the main thread, which would block the UI for a user when doing a network request. By default, URLSession dispatches network requests to a background thread, and when your completion handler is called, it is called on a background thread unless you specify otherwise. We can handle the threading with DispatchQueues or NSOperations. Most typically, if a network call finishes on a background thread, we call DispatchQueue.main.async to get back to the main thread to do UI Updates. Not doing this can cause funky UI, runtime errors and crashes.

Back

How do you mix AutoLayout with Frames?

Front

Autolayout and frames can coexist so long as they aren't mixed directly. For example, you could have a superview use autolayout, then have it's subvies use frames. The subviews would override layoutSubviews() to calculate their frames correctly.

Back

What is REST?

Front

Rest stands for Representation State Transfer. It is an API architecture built on top of HTTP. It defines how APIs should be designed. It should align with the CRUD acronym. Ideally a RESTful API would mean a resource has one endpoint to which you can GET all resources, or GET a particular resource with an ID. You could POST to that endpoint or delete an ID. It should return standard HTTP status codes such as 200 for a good GET or 201 for a good POST. Rest responses tend to JSON Rest imposes statelessness. I.e. the server need know nothing about the state of the client and visa versa.

Back

What is Serialization?

Front

Serializing means converting in-memory objects into raw data (i.e. bits) to store on disk. Deserializing is the opposite.

Back

What is MVC?

Front

Model View Controller. It is an architecture pattern defining how the app works. Model represents the data, such as array of structs of Characters. View represents the view shown to the user, responsible for showing information and responding to taps. Controller sits between the two translating user interaction to model updates or view updates. MVC can lead to Massive View Controller syndrom when one ViewController owns all the views and the model. MVVM is a pattern designed to address this.

Back

What are CGRect Frames? When and where would you use them?

Front

Frames are rectangles you can create that define where UI elements will appear on the screen. They use the coordinate system of their superviews. You define the origin x and y point then speific height and width attributes for you UI elements. They are rarely used as auto layout and constraints work better for varying screen sizes. If they are used tend to define positions based on the frames of other objects.

Back

What are properties and instance variables in Objective-C and Swift? What are type properties?

Front

Properties in Objective-C are used to store data in instances of classes. They define memory management using strong, weak or assign. When you declare a property they store their values in instances that by convention have the property name preceded by underscore. A feature of Objective-C properties is that you can use KVO to functionally react to property changes. Swift properties are typically stored properties defined as constants or variables. They default to strong but can be weak or unowned. Swift properties must be defined at initialisation of class unless they are optional. Swift properties do not provide KVO but do provide Property Observers i.e. willSet and didSet. KVO can be achieved by using the @objc modifier. Class or type properties are defined in Swift using the static or class keyword. They are defined for the entire class or type rather than particular instances. Type properties are lazy by default and are guaranteed by initialised only once. Lazy can be used on stored properties to ensure they are initialised only when needed.

Back

What is Codable?

Front

Codable is a combination of Encodable and Decodable. It is a protocol. Conforming to the protocol means your object or data can be encoded or decoded to different types such as data or json.

Back

What is the difference between `struct` and `class` in Swift? When would use either?

Front

A struct is a value type. It is copied when assigned to a new instance. It does not increase reference counts. It cannot inherit. It's thread-safe. A class is a reference type. When a variable is assigned an instance it copies a reference to that instance. It must be made thread-safe. It can implement a deinit. A struct tends to be used for simple data types or wrappers of data. As that data can copied and passed around. In a multi-threaded environment such as when opening a database connection on a different thread, structs are safer. A class tend to be used when inheritance is required, when copying an instance doesn't make sense such as a UIWindow or UIViewController, or when the class is acting like a conduit such as a APIClient or ConfigurationManager. It makes sense to have single instances.

Back

What is the difference between `let` and `var`? What differences does this have to Objective-C?

Front

A let defines a constant. It must have a value when initialised. It cannot be changed. A var defines a variable. It can change and can be unassigned i.e. nil. The difference with Objective-C is that everything is dynamic and can be nil. Nil can also be handled by throwing exceptions, whereas Swift optionals must be unwrapped.

Back

What are protocols in Objective-C and Swift?

Front

Protocols define the interface that any conforming types must implement in order to conform to that protocol. In Swift protocols can define what instance methods, type methods, properties, operators and subscripts must be available. By default swift protocol parameters are required, you'd have to add @objc to allow optional protocol implementations. Protocols abstract away the implementation detail so that you focus in the interface rather than types or inheritance trees. Protocols allow you swap implementations at runtime. Protocols make testing easier as you can easily declare mocks and stubs conforming to protocols. Protocols are a core part of the delegation pattern used frequently in iOS.

Back

How do you download images on iOS?

Front

Use a dataTask from a URLSession to fetch the data from a URL. Convert the Data into a UIImage, then you're done. Things to consider are download size and time, large images may take longer. Caching, simple caching could use a dictionary or NSCache to store images in memory against URLs you requested them from. Could use a third-party framework such as Alamofire.

Back

What is Keychain and when is it used?

Front

UserDefaults is a simple key value store that is persistent. It is encrypted by the OS and is persisted between app installs. Generally it used to store sensitive things like passwords or tokens.

Back

How do you do animation with Frames and AutoLayout?

Front

Use UIView.animateWithDuration. In the animate block change the frame or constraints. If changing constraints, call layoutIfNeeded after on the views changed.

Back

What is UIStackView? When would you use it and why?

Front

UIStackView is used as a container and makes it easy to align and resize views dynamically. It effectively manages constraints given a grid layout. It is also handing because when removing and adding views at runtime, constraints are handled.

Back

How would you cache images?

Front

Three ways. 1. In-memory cache using something like a Dictionary or more optimall NSCache, storing an image against URL to retrieve it later if it exists. 2. In database like Core Data or Realm, though not really used for larger images 3. In file system using iOS built-in File-Manager to write to a file and retrieve later

Back

What is NSCoding?

Front

NSCoding is Objective-C style Codable. It is a protocol that your objects can conform to make them easily serializable to store in NSUserDefaults, NSFileManager or Keychain. Conforming to NSCoding means you must implement an init with decode and encode from method.

Back

How would you approach major database/storage migration in your application?

Front

You'd have to ensure whatever your current db solution is, it is not tightly coupled. That is there should be a layer of classes and protocols that other objects interact with to store and get data from the database. This layer will then be injected with Core Data, for example. So long as the classes follow SRP correctly you should be able to inject Realm in place of Core Data with relatively little effort. Then you just have to code a copy from one database to another before you run the migration.

Back

What is AFNetworking/Alamofire? How do you use it?

Front

AFTNetworking / Alamofire are third-party libraries that wrap URLSession and make it easier to work with. You can use them off the bat or configure them. They handle all the things URLSession does like authentication, cookies, download types, serialisation etc. With introduciton of Codable I see them less.

Back

What are closures / blocks and how are they used?

Front

Closures and blocks are independent snippets of code that can be passed around. They can be declared inline or given there type names. They are the building blocks of async and multithreading as you can pass a closure to be ran when some other thing has finished, such as an API. They risk memory leaks by causing strong reference cycles and a conscious use of weak or unowned must be used to mitigate this risk.

Back

What are the types of iOS binaries you can create using XCode? (.app, .ipa, .a, .framework)

Front

.app - a bundle designed to represent an app. Tend to contain an executable, info.plist, resources and supporting frameworks .ipa - iOS App Store Package. The file you are given when you archive projects to be submitted to app store. .a - static libraries generated by the archive tool .framework - a bundle designed represent a framework that you can import into your project to use

Back

What is MVVM?

Front

MVVM - Model View ViewModel - attempt to solve Massive View Controller. Model owned by ViewModel, business logic in View Model. ViewController focused on view presentation. View's independent of models. Things become easier to test. ViewModel can hold dependencies to other protocols that provide functionality

Back

How do you test network requests?

Front

Generally we don't test actual network requests, unless you know you can rely on a robust integration server that gives you expected results everytime. Instead we write unit tests and mock network responses. If you build your service in layers and use completions, or promises or some sort of wrappe for the response, you can create mock responses and fire them as and when you need in tests.

Back

What is HTTP?

Front

HTTP is Hyper Text Transfer Protocol. It is the backbone of today's internet. It defines how API requests are made and received. Typically we use HEAD, GET, POST, PATCH, PUT and DELETE to talk out APIs. HEAD gets you the headers such as 200 OK or 404 Not Found. GET fetches data of a sort. POST posts data. PATCH updates a subsegment of data. PUT updates a whole part of data. DELETE deletes. They largely align with CRUD. HTTP requests achieve the majority of what we require other than real-time updates for which we can use sockets.

Back

What is the Delegate pattern in iOS?

Front

The delegate pattern is a varation of the observer pattern. It defines a one-to-one relationship between the delegator and delegatee. An example of the pattern in use is a tableView who requires a datasource and delegate. But only one of each. Protocols are often used to implement the delegation pattern. You define that your class requires a delegate that conforms to x protocol so you can send messages to it. Often delegates are declared as weak to avoid strong reference cycles.

Back

What are ViewControllers? What is the lifecycle for one?

Front

A ViewController is a class that subclasses UIViewController and must have a view to draw on. Any marginally complicated UI should use a ViewController. UIViewController gives us access to lifecycle methods so we know what the view is doing such as loading, appearing, disappearing. It also gives us easy access to presentation logic if embedded in a navigation controller or similar. Typical lifecycle event are viewDidLoad (do setup), viewWillAppear (do things that may need updating as view was already loaded), viewDidApper, layoutSubviews, viewWillDisappear and viewDidDisappear. LoadView can be used if not using nibs to load programmatically.

Back

How should consider using optionals?

Front

Be wary of using them too much due to cognitive strain and effort to unwrap and consider the optional case. Favour optional binding over force unwrapping though to avoid runtime errors.

Back

Section 2

(50 cards)

How you will store user info (username, password or token) securely in iOS?

Front

Use the keychain.

Back

How we can wait for some thread to finish before starting another?

Front

Use operation queues and add dependencies between tasks. Use a dispatchGroup, dispatch an activity to happen, call wait on the group to wait till the group finishes.

Back

Why create a custom view?

Front

To encapsulate visual appearance for a specific component in your app, that can then be reused.

Back

What does static analyser do?

Front

The static analyser runs through your code and tries to identify bugs before running.

Back

Difference between bounds and frame?

Front

Bounds is the size and location of a view relative to it's own coordinate space, frame is the size and location relative to it's superview

Back

How do you work with UIScrollView?

Front

UIScrollView is used to display content too big for the screen. Typically you constrain your scroll view to the size of the device and define scrolling behaviour. You can also become it's delegate and use methods like scroll view did scroll to define more complcated behaviours.

Back

How do you work with UITableView?

Front

UITableView is class designed to show a list of scrollable content. UITableViewCells define the content and how it's displayed. Cells and are dequeued and reused to enhance performance and reduce memory impact. UITableViewDataSource is the source of data for the view defining things like how many rows, which cell to dequeue for given indexPath UITableViewDelegate determines things like cell heights, and lifecycles such as willDisplay and interactions like didSelectRowat.

Back

Difference between viewDidLoad and viewDidAppear?

Front

viewDidLoad is called when a view was loaded, it may only be called once while viewDidAppear may be called multiple times when a view has been loaded. For example, if an app is backgrounded then reopened, viewDidLoad may not be called but viewDidAppear would be.

Back

What database options are there for iOS?

Front

Core Data - the most common. API provided by Apple. SQL under the hood. Uses an object graph which can be confusing. No explicitly thread-safe. Realm - fast, secure, cloud platform backup, reactive, queriable. Thread safe. SQL - you can store in SQL directly without using Core Data though this is rar.

Back

Why UIControl is provided if we can create custom UIView?

Front

Makes it easier to create more interactive elements by overriding control methods and responding to UIControl.events.

Back

What are the challenges in working with UI on iOS?

Front

Different device screen sizes and orientations. Safe areas of the X + screens vs iPhones with a button. Use on iPads and split screen views. UI performance with dynaimc cell sizes for TableViews and CollectionViews. Autolayout tries to resolve this using constraints.

Back

How do you optimize table views performance for smooth, fast scrolling?

Front

The main issue is calculating the correct cell height. You can use frames or constraints to get the correct cell height, but it can take time to calculate which impacts performance. You can solve this by calculating the cell height yourself and using UITableViewAutomaticDimension on your tableview or keeping a prototype cell that you fill with content and use to calculate cell height. A radical approach would be to use something like ComponentKit, a framework from Facebook designed for performant scrolling.

Back

How we can layout subviews in a view?

Front

Adding subViews will call layoutSubviews on the subview, superview and it's other subviews. Otherwise we can call layoutIfNeeded to layout straightaway or setNeedsLayout to layout on next drawing cycle.

Back

How to animate view with constraint?

Front

Use UIView.animateWithDuration. In the animate block change the constraints. Call layoutIfNeeded after on the views changed.

Back

What do you use to lay out your views correctly on iOS?

Front

You can use frames and the coordinate system. I tend to use Autolayout with programmatic constraints and snapkit. You could use an alternative such as LayoutKit created by LinkedIn to increase performance for complicated view hierarchies in scrollable views. Like lots of dynaimc content Or componentkit

Back

Difference between UIWindow and UIView.

Front

UIWindows don't have content themselves but are a container for displaying content. UIViews display content to a particular portion of the app.

Back

Explain ~/Documents, ~/Library, ~/tmp. What directory is ~ on iOS?

Front

tmp folder is mainly for stuff not required to be persisted. Library folder can store things the user need not know about or have access to. Documents folder should be available to user so they can share or access through iTunes.

Back

What alternative ways of working with UI do you know?

Front

React is an popular framework provided by Facebook for declartive UI, but it uses JavaScript under the hood. Alternatively Facebook released ComponentKit as an Objective-C++ native solution. LayoutKit is a LinkedIn version you could try.

Back

What is NSUserDefaults? What type of data can we store there?

Front

UserDefaults is a simple key-value store that is persisted on the device. It is not secure. It can store any codables. It is mainly used for simple user preferences.

Back

How do you work with storyboards in a large team?

Front

The biggest problem comes from merge conflicts on a large storyboard. Alternatives are to define UI in code or split storyboard to smaller sections of app, often one per viewcontroller.

Back

How do you check if your code has memory leaks?

Front

Could use the memory graph debugger and include live allocations to see what objects are referencing what. Could use instruments, it has Allocations tool, can be used to view allocations over time.

Back

What are layers?

Front

CALayers are simple rectangles on the screen where you may draw and display things.

Back

How do you unit and integration test UI?

Front

Standard Unit Test can test some basic UI, such as, does the view have expected sub-views, are they in the correct state, enabled etc. correct labels. Snapshot Testing is a recent way. You record a snapshot image of your view, then test whether your code continues to match the snapshot. XCUITesting is another way to test UI but more typically test user flows and element existence.

Back

Why do we override drawRect: method? How to explicitly call it?

Front

Don't call it. Call setNeedsDisplay. Override to implement custom drawing logic. For example, you may start drawing bezierpaths or arcs.

Back

Notifications remote? How?

Front

Enabled push notification capability in app. Creates a new App-ID. Request permissions from user for notifications. Call UIApplication.shared.registerForRemoteNotifications. Use AppDelegate didRegisterForRemoteNotifications to get device token. Notifications are sent. AppDelegate launchOptions will contain infor or didReceiveRemoteNotification. Payload is simple json telling you about the notification. You may have to create a new key in your certificate to test notifications.

Back

What is bundle?

Front

Bundles are simply directories, but Apple use them with the .app and .framework extensions to bundle up app executables and frameworks and resources. The bundle can be used a referenced in code.

Back

What design patterns are commonly used in iOS apps?

Front

MVC - Model View Controller - design pattern for splitting UI, interaction, and data. Advocated by Apple. Good for small apps. Can result in Massive View Controllers. Singleton - one and only instance of objects. OK for somethings. Used for UIApplication instance for example. Can be overused. Dangers of global state, race conditions, difficulty testing, lack of dependency injection. Delegation - variant of the Observer pattern where one and only one delegate is responsible for dealing with activity. Used in things like TableViews and Delegates. Observer - observers can subscribe to observees it you like and respond when the emit events. Can have multiple observers. Used in the Notification Center and if you use Key-Value Observing. Also a prominent feature of RxSwift if you use it. MVVM - Model View ViewModel - attempt to solve Massive View Controller. Model owned by ViewModel, business logic in View Model. ViewController focused on view presentation. View's independent of models. Coordinators - split responsibility for navigation and user flows out of View Controllers and parent Navigation Controllers, useful for deep linking. Easier to test.

Back

What is MVC? What are benefits and negatives? Alternatives?

Front

MVC - Model View Controller. Model is the data - domain model objects Views - are views showing things to users and interpreting input Controller - is business logic, handling data changes and telling views to change. Advantage - easy to understand, quick to implement, good for small apps and new developers Disadvantage - iOS ViewController becomes too large with too many responsibilities, violates SRP, becomes more difficult to test Alternatives - MVVM-C, general conscious use of SRP to layer the architecture more, so network clients and database clients

Back

What are the compression resistance and content hugging properties?

Front

They define how likely your view will be squeezed or expand given other constraints. A high compression resistance means your view is less likely to shrink if another constraint forces it to. A high content hugging property means you view is more likely to hugh it's content rather than grow. Often these are used with labels as you may want a label's size to stick to it's intrinisic content.

Back

What is AutoLayout? When and where would you use it?

Front

Autolayout is Apple's way of defining layouts based on constraints and relative positions of views. Constraining the width height or position of elements means Autolayout can determine the correct frame to give the view. Constraints can be defined in code, storyboards or nibs. Constraints have a number of different options including should they be equalTo, lessthan or greater than, what is their constant and what is their priority To make working with constraints easier you could use something like SnapKit or PureLayout.

Back

Can we have multiple UIWindows in iOS?

Front

Yes, if we have multiple screens for example.

Back

What is Wildcard App IDs?

Front

Wildcard app id can be used to build the majority of apps whereas explicit App IDs are required for push notifications and in-app payments. Xcode automatic signing tends to handle this.

Back

Have you uploaded app on Appstore? What is the process?

Front

Create a provisioning profile and certificate for distribution. This can be automatically handled for you by Xcode and App Store Connect if you want. Archive a version on Xcode, may have to increment version and build for an updated app. Create or create new version of app in app store connect. Fill in data. Add your build. Submit your build for review. Alternatively submit to TestFlight for beta testers.

Back

How we can execute some code when app is in background?

Front

Yes. Either use a backgroundTask to gain sometime when the app is backgrounded. Or use Background Fetch capability, this will launch you app in Background to perform activity. Can also achieve this by subscribing to certain API's like significant location changes.

Back

Explain concept of notification center, local?

Front

The Notification Center uses the Observer pattern. Objects can register themselves as observers or listeners for a particular notification and target a method. When that notification is posted the observer can respond and process. Used locally it's as simple as post notification and observing. Remember to remove observers before deallocation.

Back

How do you make a pixel-perfect UI according to a designer's specs?

Front

Ideal world the designer would have considered ever edge-case, screen size, data possibilities, but the reality is pixel-perfect design is difficult. Best solution is a quick feedback loop between you and designers, stakeholders and testers so you can find edge cases and deal with them quickly

Back

How we can do multithreading in iOS?

Front

Use Grand Central Dispatch to dispatch blocks to background threads. Alternatively use OperationQueues for more control, e.g. adding dependencies between queues, monitoring queue progress, controlling number of concurrent tasks. Or a DisptachGroup to process multiple things concurrently and wait for all to finish.

Back

Explain application life cycle or application states.

Front

An App is either not running or backgrounded. At some bottom it launches and becomes active. It can then become inactive, be backgrounded and finally terminated. All this lifecycle states are received by our AppDelegate. Methods like appWillLaunch and didLaunch gives us time to setup and prepare our app. The App may resignActive for phone calls and then becomeActive again. The App can be backgrounded by user. The App can be terminated by user or purged from memory by the OS.

Back

What can you use to store data in iOS?

Front

In memory constructs like arrays, dictionaries and sets. They can't store lots of data and aren't readily persistable. UserDefaults / Keychain. Simple key-value stores, one insecure, the other secure. Easy, fast and persistent. Can't handle lots of data or extensive querying. File / Disk Storage. Stor files and data to disk given a URL. Persistent. Not query or database like. Databases like Core Data or Realm. Bigger setup but more querying, storage, complicated relationships.

Back

What is the difference between static and dynamic libraries?

Front

Static libraries are compiled and included in the executable. Static libraries are linked at compile time. Every app using the library gets its own copy, increasing app size. Dynamic libraries are outside the executable and can change. Dynamic libraries are linked when loading or at runtime. Apps can use a single copy.

Back

How is data mapping important when you store data?

Front

The main thing to consider is that when you load from the database, data will go from database to raw data objects to your custom doman models and visa versa. As an example querying Core Data will get you back NSManagedObjects, you could skip a step and use these across your application, but then you are tightly couple to Core Data, plus you lose thread-safety. So it's better to map data to and from NSManagedObjects. Likewise, when using UserDefaults or the keychain, you have to grab the raw data, then somewhere deserialize that data to your custom objects for use. So data mapping should maybe it's on layer between db retrieval and saves to help loosely couple.

Back

What are benefits of collections views?

Front

CollectionViews allow you to have TableView style functionality with added customisations. Such as varying scroll directions. Grid style layouts. Different cell shapes and sizes. Can implement drag and drop. Multiple cells in one row.

Back

Difference between Developer and Enterprise Developer accounts?

Front

Developer accounts intended for app store, enterprise accounts intended for distributing apps through an enterprise

Back

Common reasons for app rejection from Appstore review process?

Front

Crashes, bugs, placeholder content, misleading users, poor user interface against guidelines.

Back

Difference between linking and embedding a framework?

Front

Embedding a framework will include the compiled framework in your app or framework.

Back

Is UIKit thread safe?

Front

Drawing is apparently thread-safe, but not all UIKit is, hence it tends to be used on the mainThread.

Back

Difference in Xib/storyboard vs nib?

Front

Xibs are interface builder files that define UI, when compiled they become nibs. For the most part they've been replaced by storyboards.

Back

What are various singleton instances provided by frameworks?

Front

UIApplication.shared, FileManager.default, UserDefaults.standard, URLSession.shared.

Back

What are different Instruments Xcode supports for app profiling?

Front

CPU profiling, memory profiling and time profiling.

Back

How does Autolayout work with multi-threading?

Front

Every UI change must be done on the main thread. If you change a constraint then do it on the main thread. Call setNeedsLayout to make UIKit aware it needs to update.

Back

Section 3

(26 cards)

What are provisioning profiles and certificates?

Front

Provisioning profiles detemine who can run an app on their phone. A profile is required to run the app. Profiles contain approved app ids, device ids and certificates. A developer must have the correct device and signing certificate in order to use a profile to build an app.

Back

Basics of Core Data?

Front

Basics is, you have a data model, the data model is represented in code as an NSManagedObjectModel. You also have an NSManagedObjectContext that you interact with most. Then you have a persisitant store coordinator that manages the store and interacts with the context and the model. The NSManagedManagedObjectContext allows you to fetch, add, delete ObjectModels.

Back

What was the latest version of iOS you worked with? What do you like about it and why?

Front

iOS 13 SwiftUI Functional Reactive

Back

What are the design patterns besides common Cocoa patterns that you know of?

Front

Factory Factories are used to build objects conforming to types or protocols at runtime while hiding implementation details. A good example is using Factory for consistent design elements, such as requesting a TitleButton from a Factory. You know it will give you a UIButton, but the factory controls to style. Adaptor This is used to adapt functionality to work with something. Often used to handle third-party code you don't have access too. An example, if you have a User class that determines what a user is, and you have a shareable protocol that defines methods that provide a sharing titile, and sharing detail. You may not want User to conform to Shareable as that would violate SRP. So you have a UserSharableAdaptor class that conforms to Shareable and is injected with a User. The adapter users whatever data it needs from the User, and adds any text to conform to the Shareable protocol such as the title could be "This is user \(user.name)" Decorator Decorators take in certain types or protocols, then enhances their functionality by also conforming to the type or protocol. For example, you have a Product protocol. It has a price and a name. You have a instance of type FullPriceProduct that conforms to Product. You want to discount it so you init a DiscountProductDecorator, that expects an injected Product, and conforms to Product itself. In it's internal implementation it takes the price of the injected product and discounts it before returning it through it's Product interface. Command TBD Template The template pattern defines a baseClass that has numerous methods that inheriters must implement. You may use when you want all subclasses to follow a similar process for achieving their functionality. For example, you may have a ReportGenerator base class that requires implementations of inputtingData, processingData, and returningData. Each subclass will have to implement these methods. An example of a template is UIViewController, that has viewWillAppear, viewWillLoad, viewDidAppear etc. all places you can hook into the original algorthym

Back

What is BDD?

Front

Behaviour Driven Development, similar to TDD but more focus on close relationship between coders and testers and shared understanding of the behaviours of users and how the app might fulfil behvaiours

Back

Explain how you can add frameworks in Xcode project?

Front

You can add frameworks manually going into your build settings and either linking a framework or embedding a framework. Alternatively you can use a dependency manager like CocoaPods or Carthage.

Back

How many types of background modes supported in iOS?

Front

Audio, background fetch, location updates, Voice, bluetooth, notificaitons.

Back

What is a framework?

Front

A framework is a type of bundle. Essentially a directory with compiled code and resources that you want to use.

Back

What does the keyword `defer` do?

Front

defer is used to defer a block of code to execute after the current scope ends. A use case, you may have a function that does some writing to a file and you might defer closing the file till after the write function completes.

Back

What is an App Extension?

Front

App Extensions are areas you a can extend the functionality of your app. For instance you can show your app as a widget on the Today screen, you can let your app apply photo filters in the Photos app, you can have your app be a custom keyboard system wide, you app could become a file store provider.

Back

What are the SOLID Principles?

Front

S - Single Responsibility Principle - every class should have one and only one reason to change Basically a class should do one thing and do it well. As an example, if you have a model object that models a Location on a map. It should only care about modelling that data, so it may have a coordinate. But it would not contain any logic to fetch locations, or render a location on a map. O - Open/Close Principle - classes should be open for extension but closed for modification. This means you should be extend or change functionality without changing a class itself using protocols, abstraction and polymorphism. Two examples. 1. If you a Storer class that saves things to a database, it should be dependency injected with a protocol that wraps a CoreData implementation. If you want to change to Realm, your make a Realm wrapper conforming to the same protocol that the CoreData class did, and inject a different class. 2. Avoid switches. If you have a location and give it an enum of type, such as restaurant, pub, fuel station, every knew type will need code to change wherever you switch on type. Instead, create a protocol of type Location, then provide specific instances of RestaurantLocation, PubLocation. Each location instance can use the protocol to provide information about how to display itself, or what icons to show for example. L - Liskov Substitution Principle This is like Protocol-Oriented Principle. If you subclass and class that conforms to a protocol, that subclass must conform to the protocol too. So that any classes using the protocol (interface) don't need to worry that an implementation detail has changed. I - Interface Segregation Principle. No class should depend on interface methods that it doesn't use. Make your interfaces specific rather too general. You don't want a class to conform to a protocol then have 2-3 methods in that protocol that do nothing. D - Dependency Inversion Principle Depend on abstractions not concretions. In Swift we achieve this with Protocols. Don't inject concrete objects as you end up with tight-coupling and people can end up overusing inheritance. Use protocols to wrap concrete objects so you can switch implementations easily for easier testing and easier code changes in future

Back

What are the common layers of responsibility that an iOS application has?

Front

UI Layer - Views and ViewControllers Service Layer - API Clients, Networking Wrappers Storage Layer - Core Data, Realm, Keychain, Defaults Business Logic Layer - ViewModels, Coordinators, things that depend on the Service or Storage layer but implement logic prior to fetching data or saving data.

Back

What is NSPersistentStore ? Is it thread safe?

Front

It is the core data store, it is thread-safe as it uses locking.

Back

Can you pass data between apps on iOS?

Front

Yes - 1. UIActivityControllers where you can share from your app to differenct sources. You can say your app accepts certain file types, then use app delegate methods to handle incoming files. 2. URLSchemes, expose url schemes you accept, use appdelegate methods, this means URLs can open your app to specific places. 3. SLComposeServiceViewController can be used for easy social sharing 4. App groups can be used for single developers to share certain app access. 5. Shared keychain access acroos same developer. That's about it.

Back

How do you manage dependencies in iOS applications?

Front

Tend to use a dependency manager, either Cocoapods or Carthage. Cocoapods creates a Pods project in your Xcode project that has the benefit of showing the implementations of certain third-party frameworks. Cocoapods is slightly less flexible. Carthage more flexible but some people find it hard to use. Carthage does not, it builds the binaries in a seperate folder in your project, then you can import the frameworks into your project. I like Carthage because it hides dependencies a bit more allowing me to focus on the current project. Could also use Swift Package Manager, not tried yet.

Back

How to de-symbolicate crash log?

Front

You need the .crash log and the equivalent .dsym file that was generated for the instance of the app. This will be in your archives in Xcode or available on AppStore Connect. Xcode now automatically tries to dysym crashes if you pull the crash log into device log area

Back

What is TDD?

Front

Red Green Refactor - You must not write production code until you write a test, you must write no more of a test than is enough for it to fail, you must not write more production code than is necessary for it to pass.

Back

What is functional and functional reactive programming?

Front

Functional Programming is a declaritive style of programming rather than imperative. Meaning you declare what your code should do over how it do it. It focuses on using functions as first-class citizens, avoiding mutation and use of in-out-functions. The idea being these can be predictably tested and reduces side-effects. Swift provides for functional programming with value types and methods like map, compactmap and reduce. However it is not fully functional, though it can become more so if you implement your own custom operators to provide function composition. Functional Reactive Programming builds on top of Functional Programming by supporting asynchronous data flows. It introduces the concept of time by wrapping typical variables in something that expresses the variable over time. Frameworks for achieving this include ReactiveCocoa and RxSwift. RxSwift uses Observables. You can observe observables over time and do things when observables emit events.

Back

Difference between version and build?

Front

Version is the marketing version that correlates with app store. Build is build number, often teams auto-increment this to reflect all new builds of the bundle.

Back

What is NSPersistentStoreCoordinator? What duties does it perform?

Front

The persistent store coordinator is mainly responsible for understanding the NSManagedContext and managing the actual persistent store.

Back

Do you need a new certificate for push notifications?

Front

Think so

Back

What certificates and profiles do you need to launch an app in the App Store?

Front

You just need specific distribution profiles and certificates, Xcode tends to automatically manage this.

Back

What is the difference between bundle ID and app ID?

Front

App ID uniquely identifies an app in App Store Connect, Bundle ID uniquely identifies app in Xcode for builds

Back

What is a dispatchGroup used for?

Front

DispatchGroup is used when you want to run a number of tasks and wait for them all to finish before doing something else.

Back

What features of Swift do you like or dislike? Why?

Front

I like type inference, clarity, functional aspects, cleanliness.

Back

What do exception breakpoints do?

Front

Exceptions happen when code doesn't catch errors that throw, this may happen in your code or third-party libraries. Exception breakpoints will catch these failues and show a stacktrace.

Back