Download presentation
Presentation is loading. Please wait.
Published byΉράκλειτος Σκλαβούνος Modified over 6 years ago
1
A lighting tour™ to iOS Plus some fun stuff
Victor Wang, Software Engineer & Technical Consultant November 10, 2016
2
iOS Programming - How to?
How are iOS apps structured? Model - View - Controller How are UI components (UIButton, UILabel, UITextField etc.) controlled by code? View rendering How to quickly prototype something? Use storyboards. But it has its own quirks. How to develop iOS apps modularly When you want another feature, simply add a module When you want to deprecate a feature, simply remove that module MVC, View population cycle, Storyboard
3
iOS Application Structure
Makes extensive use of M (model) V (view) C (controller). In the context: M: model (store) that stores reminders Expose API for get/set C: controller (ViewController) that controls how data from store is displayed Call get/set from model -- get data Use that data to set view V: view that defines how the UI looks Expose APIs for set particular components
4
How are UI components controlled by code?
View exposes API Controller knows about the API and call them Well-defined and structured in iOS ecosystem What about something like that ? → Autolayout Defines how components should align with each other or relative to edges of screen Tool: InterfaceBuilder View Rendering cycle viewDidLoad viewWillAppear viewDidAppear
5
Using Storyboard Best prototyping tool WYSIaWYG
Handles view hierarchy initialisation for you Although sometimes you may not want it Save the amount of code you write just to define UI WYSWYG makes UI debugging easier Segues The transition from one VC to another VC Also takes care of initialising the destination VC Is also how you pass data to the destination VC
6
iOS APIs Being a good iOS developer means understanding iOS APIs and the design thinking behind it. Everything you touched so far is iOS API View and how views are displayed UI Components UI Component properties and methods Rendering cycle
7
Tackle a ubiquitous VC: UITableViewController
What is delegation Vital in iOS APIs because they are everywhere, especially in hierarchical views What is a data source How iOS design thinking made early version of iOS much smoother than Android Is also why iOS devices can perform relatively well with way less RAM A little complex Tackle a ubiquitous VC: UITableViewController
8
Delegation & Protocol Problem Solution
Sub view is controlled by a controller nested in a parent VC Sub view wants to Call a method in parent VC Pass data to parent VC Basically: all sort of interactions Solution Have sub view own a delegate of parent VC When parent VC initialise child VC, set child VC’s delegate to itself Child VC use delegate.”whatever()” to call parent VC’s methods Another Problem: both child VC and parent VC need to know about these available methods Child defines a protocol which the parent will implement A protocol is a set of predefined method headers
9
Put in context tableView doesn’t know anything about TableViewController tableView needs information from TableViewController to set its cells This includes title for the cell, content for the cell How many cells? How many sections? Cannot blindly pass all the data to tableView because you create redundant copy Memory is expensive and very limited resource on iOS devices iOS defines two protocols UITableViewDelegate UITableViewDataSource
10
About memory (RAM) Smart strategy iOS makes to save RAM
TableViewCell - quite a number of them can be based on the same template (a title, some text, maybe adding a button of sorts…) Why not reuse them? When tableView is initialised, cell height and screen height is calculated to determine how many cell needs initialising and put in RAM After that, when cell is scrolled out of visible range (screen) it is recycled and populated with new content to be displayed at the opposite end of screen Very efficient because the total number of cells stays the same (not overflowing RAM)
11
Extends your app modularly
Very cool 3rd party tool that gives you access to a number of libraries you can use to make your code more concise/readable/fast Do not take everything because app size is also important. You don’t want user to download an app that’s 500MB with very limited features. Understand the consequences and always install pods wisely CocoaPods Extends your app modularly
12
So many topic to be covered
Web requests How to open a web page How to make HTTP requests GET/POST/PUT How to handle JSON data Maps How to show where the user is What used to be offered in iOS 2 is an app that retrieves a set of locations of all the coffee shops on campus and use your location to determine which one is the nearest to you So many topic to be covered iOS is huge but the it is designed to be understandable (we already covered its core design thinking)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.