Swift Language Flashcards
Internationalization
It is the process of making your app able to adapt to different languages, regions and cultures. In our case adapting multiple screens and platforms.
Autoresizing Masks
Automating the response to external UI. It programmatically controls frames. If the user changes the font size while your app is running, both the fonts and the layout must adapt.
Auto Layout
It’s better than Autoresizing masks. Instead of the view’s frame, you think about its relationships. It uses constraints. This produces layouts that dynamically respond to both internal and external changes.
Bounds
The bounds rectangle describes the view’s location and size in its own coordinate system.
var bounds: CGRect { get set }
In default, it’s set to (0,0) of the view but you can change the value to display a different portion of the view.
Draw(_ : )
Draw’s the receiver’s image within the passed-in rectangle.
func draw(_ text: CGRect)
You can get a reference to the graphics context using the UIGraphicGetCurrentContext() -> CGContrxt?
setToolbarHidden(_ : animated: )
Changes the visibility of the navigation controller’s built-in toolbar.
func setToolbarHidden( _ hidden: Bool, animated: Bool)
True: hide the toolbar
False: show the toolbar
True: toolbar animated when screen is on or off
navigationControllerSupportedIntrrfaceOrientations(_:)
Returns the complete set of supported interface orientations for the navigation controller , as determined by the delegate.
Optional func navigationControllerSupportedIntrrfaceOrientations(_ navigationController: UINavigationController) -> UIInterfaceOrientatinoMask
Linked Lists Definition 1
A fundamental programming concept, linked lists provide the foundation for many algorithms and data structures. Available in print, ePub or pdf format this unique essay introduces linked lists with Swift.
Linked List Definition 2
Linear Collection of data Elements, every data item represent a node.
There are two types of Linked Lists : -
- Singly: Points to optional next-node
- Doubly: represent two pointers to next and previous
Core Motion
Receive and handle accelerometer events and other motion events.
Custom App URL Schemes
URL Schemes, every device can have a specific URL scheme. ‘http://’ hopping from a web device into the application
Add key value pair to info.plist
after we redirect a url to our app, we use OAuth (Token or Flag)
App delegate take care of things before we get directed to the application.
OAuth
It is an authorization Protocol - set of rules that a allows a third - party website or application to access user’s data without the user needing to share login credentials
HTTP vs HTTPS
HTTP send the data in plain text without any encryption.
HTTPs does the encryption over the wire
OAuth Workflow
Call Back URL
1- User make an action from the app to the service
2- The app redirects the user to the service provider for authentication
3- User gives their permission for the service to use their timeline (eg. accessing their twitter photos)
4- Service provider returns the user to the consumer app with a code
5- Consumer sends the temp code with a secret key to the service provider in exchange for an authentication token.
6- The user performs actions and we pass the authentication token with each call to prove who they are.
Once the browser redirects us to the app, the app should handle the information passed in and ask the server for a token.
Most Common HTTP Methods
GET - retrieve resource at the url
POST - request that the sever accept data enclosed in the request. Creating a new record like posting a tweet
GELETE - delete a resource
PUT - updating a preexisting record
Domain - The physical server where the website is hosted
URI - The identifier which maps the files on your server
Query String - Part of a GET request to easily pass in values to customize the outputs
www.luay.com //the domain
/whatever-in-the-url? // the question mark is the end of the url and everything that follows are key value pairs that are related to the query as the following:
/key:value&key:value
API - Application Programming Interface
All the applications we have now a days are Front Ends for a Web API.
Web APIs, what you will be working with, are defined as a set of HTTP requests and response messages usually in JSON or occasionally in XML
REST
REST is an acronym for REpresentational State Transfer. It is not a protocol, it is just a architectural style
The server doesn’t care what app or device we are using to request the data. The only thing the server cares about is to know where to send the data back to the user.
REST API
Cacheable - Responses must defines themselves as cacheable or not (The cache should be handled by the user/client though)
Code On Demand (Cool feature!)
Simply an update that happens without hitting the app update on the app store. Like Instagram/snapchat filters that show up out of nowhere!
URLSession
It’s highly Asynchronous unlike CIImage which was not Asynchronous.
The URLSession class and related classes provide an API for making HTTP requests
URLSession provides two ways of interacting with RESTful services… with completion handlers (closures) or delegation
All http requests made with URLSession are considered “Tasks”. A task must run on a session (URLSession class)
Three types of tasks: Data tasks - receive and send data using Data objects in memory. Upload tasks - send files w/ background support. Download tasks - download w/ background support
URLSession is initialized with a URLSessionConfiguration. URLSessionConfiguration has 3 types: Default session - disk based cache. Ephemeral session - no disk based caching, everything in memory only. Background session - similar to default, except a separate process handles all data transfers
Configurations have many properties for customization. For example you can set the maximum number of connections per host, timeout intervals, cellular access or wifi only, and http header fields
URLSession also has a sharedSession singleton available to use based on a default session
AppDelegate
The AppDelegate in your app is a regular object that conforms to the UI Application Delegate Protocol
UIApplication Delegate Protocol
Contains your apps startup code
Responds to changes in your app’s states (foreground to background, etc)
It responds to notifications originating from outside your app, like remote notifications, low memory warnings, download completions, etc
Can be used to store app’s central data objects or any content that does not have an owning view controller
UIWindow is part of UIView
UIWindow is a class that manages and coordinates the views an app displays on the device screen.
Windows have 2 main jobs, provide area for displaying other views, and distribute events to the views.
UIWindow has a rootViewController property, which can be set to change the root view controller
The UISearchBar class
The search bar provides a text field for text input, a search button, a bookmark button, and a cancel button
Relies on it’s delegate to perform searches when one of its buttons is pressed
Can be also embed into a tableview by dragging it into the tableview on storyboard
Just like UITableView, we conform to the UISearchBarDelegate protocol to implement the methods we want for handling user input.
searchBar(:textDidChange:)
searchBarSearchButtonClicked(:)
Closure Based Animations
Spring Animations
presentSafariViewControllerWith
The in-app safari browser
1- import SafariServices
2- instant - FSafariViewController(url:URL)
3- self.present(safariController, animated: true, completion: nil)
REGEX on IOS
To create regex we need an extension that uses Validate on our String