Uploaded by joe

COMP228 - App development

advertisement
#separator:tab
#html:true
Delegate?Code that provides some addtional functionality by providing specific methods, which can be invoked when required by another class<br><br>e.g Apple's IOS runtime dosen't create a window for you and setup losts of other objects, because it dosen't kn ow what you need. Instead, you create a customised delgate object that is then linked to the runtime , adn in that ** you* create a window and have methods that can handle the events that you need to. The runtime invokes methods in that object for you at the approriate points during it's lifecycle.
App delegateA singleton delegate object that provides specific methods to handle events that occur as part of the lifecycle of an APP.<br><br>e.g you App starting up. Your App's window contents being drawn on the screen. Your app closing down.
What is a tuple?"multiple values grouped into a single value<br><br><img src=""paste-e93761f6a90e723d48e2d34cab8ab77a250f9a06.jpg""><br><br>We can name the elements when we delcare a tuple<br><br><img src=""paste-adce748d65701a75d325a03fde2a520b5abd5ce2.jpg""><br><br>This can also be done numerically<br><br><img src=""paste-e9ca1923c33445c590d579fd1f6ed162abf33f3b.jpg""><br><br>Tuples can also return more than 1 value from a function:<br><br><img src=""paste-f1a550577d13e43ee0bbbf713eb5dc92ee49b264.jpg"">"
Describe how optionals work?"Optionals are used where a value may be absent e.g trying to convert a string to an integer<br><br><img src=""paste-97063771603fd0767d3dcf13dfec8a8ed0349eaf.jpg""><br><br>Defining an optional variable automatically intialises it to nil as seen below<br><br><img src=""paste-7203e83bffd7e71ad7fbd9a6ee5fa6b76da2fef9.jpg""><br><br>if an optinal has a value you can access it by adding a exclamation mark '!' to the end of its name this is called forced unwrapping<br><br><img src=""paste-3e27d3e8e5a96596943e61332243ca741aae9fe2.jpg""><br><br>?? is a nil coalescing opeator ( means if not it is the one after) <br><br><img src=""paste-6f9b60fb68a6730fdc10aed3735a6d053696e19a.jpg"">"
name the collection types"Arrays, these are ordered collections of values<br><br><img src=""paste-fed54615b2faeb7ddbc213cb083b8f15ccb24b56.jpg""><br><br>Sets, these are uordered collections of unique values<br><br><img src=""paste-4de9164c017a147dc085e4c14dd246a9596deeb5.jpg""><br><br>Dictionaries, are unordered collections of key value associations<br><br><img src=""paste-430c37bd2d67346b81e3eec796fe3a816a96f165.jpg"">"
Describe an Array "Arrays are ordered collections of objects, info below<br><br>- variable arrays are dynamic, ie they can change their size or values, etc.<br>- Elements of array are ussually of the same type (but can be different types and then need ot be declared as [any])<br>- typically, values at some index are accessed<br>- index always starts at 0<br><br><img src=""paste-d7c7a839f7f5dcdd62f560b2a00c0d5571208736.jpg""><br>"
Below is an example of how arrays can be added together to create a longer array."<img src=""paste-34668edb6236f40ecd7e919dc9d4273807bc7aec.jpg"">"
How different arrays are sorted"<img src=""paste-585875d02d36031c1263afc91918b3d7f6990961.jpg"">"
Describe how sets work"Sets manage unordered items<br><br>- they can be used as an alternative to arrays when the <b>order is not important</b> <br>- memebership testing is faster with sets than arrays<br>- good for maintaining collections of items when membership, or intersection with other set collections is required<br>- .count returns the total number of objects in the set<br><br><img src=""paste-bc158aacd7aab3e3a6acec912e6febc1b27a9187.jpg"">"
How can sets perform set operations on a set, remember what they are: Intersection, symmertic difference, union and subtraction"This is a visual representation of the different set operations<br><br><img src=""paste-30650b61d7d603b8bac9c7f0e4c91985e395013e.jpg""><br><br>in swift below<br><br><img src=""paste-2fc298ea3d6b86fb0a65a64cdf7d3c3cdaf4cd78.jpg"">"
How do sets use equality, subset, superset and disjoint?"<img src=""paste-4f1b4943eb172a56958459f0caae46fb7ec98514.jpg"">"
Describe how dictionarys work"Dictionaries manage unordered collections of key value pairs, each entry consists of :<br>- a value which can be any object<br>- a key which is unique. This key can be any object but is most commonly a String<br>- In general the keys are all of the same type<br>- in general the values are all of the same type<br><br><img src=""paste-311b7deb7b6621c68b749e39f861f490a9328ace.jpg""><br><br>Below is different code on how a dictionarys functionlity works<br><br><img src=""paste-21e0b5f0ed7a92282f518a397101d64ede08eebf.jpg""><br>"
How would the code for a dictonary work when calling a specific value"Retrieving an item froma  dictioanry, always results inan optional.<br><br><img src=""paste-7837bced79109e5ca301d7d532bfb7d7f3c732d3.jpg"">"
Describe ranges?"It is a non standard type,<br>- it can be thought of as just two end oints<br>- this can be used to represent for example a selected biy of text or a portion of an array or a section of a string<br>- implemented as a structure<br>- the end points must be comparable type<br>- one type of range is CountableRange which is good for iterating over<br>- ranges can be declared using ...< or ...<br>- values range from lower bound to less than uppper for ..<<br><br><img src=""paste-8f7c10e72c3e70d1c37cc890e3dced41d0aa9911.jpg"">"
How do arrays work in for loops also using enumarated"<img src=""paste-54ef3f2946dc2075de0a08f022f9d16b565ef45a.jpg""><br><br>But what if you want to modify an arrays context?<br><br>use enumerated() which returns a sequence of pairs (n, x). n i s consecutive integer starting at zero and x is the next element in the sequence.<br><br>You can use an index to acces the appropriate element of the array<br><br><img src=""paste-86b64f8ce68f615e4e23bde48c6a3317049d2c10.jpg"">"
sum up of collection types<div><div>Arrays, sets, tuples and dictionaries all let you store groups of items accessed via a<br>single variable (or constant)<br>• They do this different ways, so you have to choose the one that fits with what you<br>need for your code<br>• Arrays store items in the order you add them, indexed by integer (starting at 0)<br>• Sets store items in an undefined order - you can’t use a numeric index to access<br>them<br>• The number of items in a Tuple are fixed, once you’ve defined it. You can attach<br>names to the items, and access them using their names, or a numeric index.<br>• Dictionaries store items via keys, which are used to access the items. The order<br>they’re retrieved is otherwise undefined. Retrieved values are always optional +.<br>+ (Unless you somehow supply a default)<div></div></div></div><div></div><br>
How can init() be used?"intialisers - called when new instance created.<br><br>simplest intialiser defined like an instance method with no parameters. method named init()<br><br>shown below is an example<br><br><img src=""paste-c39d6156be455846cb3de0399823af6a6c644a8a.jpg"">"
How would initialisatoin parameters be used?"If they are used, it defines the types and names of values to customise initialisation process<br><br><img src=""paste-cdd0974179ec0e7f9d8b11752c38878ddc64403f.jpg""><br><br>"
Describe how enumerations work?"It is an object type whose instances represent distinct predefined alternative values<br><br>within enumarations,<br>- can add an optinal type declarations, cases all then carry a fixed constant<br>- if int, values can be assigned but start at 0 by default.<br>- If string, values are string equivalents of case names<br><br><img src=""paste-3e89a408156ccee796dc83251f5e4f78c6af88b2.jpg""><br><br>Enumarations can also assign values explicity as part of the case declarations and use those raw values to map back to the associated case<br><br><img src=""paste-c1bd272911fd7eb6b38bb9d800f543123b439fb8.jpg"">"
How do enumerators use isntance and static methods"They always define a multi state variable yourself, but enums handle bounds chekcing automatically and are very readble in your code.<br><br>Even values in your code that are 2 state may be better as enums rather than Book (especially if its not true and false for example it could be on and off)<br><br>One handy mapping is that the secitons of an IOS segmented control start from 0 - so you could represent each option as a case in an Enum as shown below<br><br><img src=""paste-c44836609f45e3c3cdf7feb61f3e69b75d52d19b.jpg"">"
Describe how protocols work and defined"- Protocols are object types, but without the protocol objects<br>- It is not instantiated by your code<br>- Works as a list of properties (without values) and methods (with no code!)<br>- Think of them as a named contract that someone will conform to.<br>- A ""real"" object type formally declares it belongs to a protocol type (aka adopting or conforming)<br>- That object type must implement those properties and methods itself.<br><br><img src=""paste-d37890007a468229c5d26f13127c49a97b735be3.jpg""><br><br>Above you can see the protocol definition dosent include the body of the method. We can add a comma seperated list of protocols after the superclass name.<br><br>- in the protocol, property requirements are always declared as vars.<br>- Protocol dosen't require that the property should be stored one, or a computed one. Only the name and type of the property.<br>- Also specifies if the property should be gettable or settable<br>"
"using the given protocol describe its functionality<br><br><img src=""paste-8056d6b7291ec527e166a0009bd3bf8598c6e3bc.jpg"">""- The FullyNamed protocol requires a conforming type to provide a fully qualifed name.<br>- The protocol dosent specify anything else about the nature of the conforming type - only that the type must provide a full name for itself.<br>- The protocol states that any FullyNamed type must have a gettable instance property called fullName, which is of type string<br><br><br>Because it is only a getter method  it can be satisfied with let, var and more whereas a getter and setter method cannot be defined with let (a constant) or be computed by one , new example below:<br><br><img src=""paste-5b82e2c23c8078304accbfb00ed249d68e615bd3.jpg"">"
benefits of protocols- good way to define a set of required functionality that other types can adopt.<br>- Ensures that an adopting type has the features you require.<br>- by adpoting some apple standard protocols your class / struct instances get some additional features / become better inegrated with the O/S e.g hashable
How can you avoid the pyramid of doom with if statements"Use guard statements, this lets you test for what you want, and handle the situation when it's false, allowing for your code to not end up massively indented therefore easier to read.<br><br>Below is an example:<br><br><img src=""paste-2b6701895002df34d77fdf12ad5c20b3253eb671.jpg"">"
How would you error handle in swift?"You can define functions and emthods that throw errors in the event of an unexpected situation<br><br>You can implement this, first declare an enum witha  case for each sort of error that you expect<br><br><img src=""paste-0a33bd971c19263494023ae256eab2bdf7b584e9.jpg""><br><br>Then your throwing function should check for the various errors and throw the appropriate enum member.<br><img src=""paste-89358153ae4d61cda1b42967150ee76347e808d0.jpg""><br>Where you call your throwing function, you need to wrap that in a do {} and prefix the method call with a try, handling the result with a catch<br><br><img src=""paste-304a7ca295b49003b837dff26f3abe9b73c0014f.jpg"">"
Method syntax, what does each method method declaration consist of?"<img src=""paste-6d3d68a1ddcc472d8ce90a1fdeb8e2dbab781e17.jpg""><br><br>It is possible to supress parameter names then the method is being called.<br><br>By default methods use thier parameter names as lables for their arguments , through this you can create a custom argument label before the parameter name, or ""_"" to use no argument label.<br><br><img src=""paste-5e0d2bc558fa6fb505ff750020e6304b131b8285.jpg"">"
How would you create an instance of a method, there are 4 ways"example provided<br><br><img src=""paste-b0e36bd5a412d7a99992366a43675262a69fdb13.jpg""><br><br>methods in swift can also have default values, you can replace all four intialisers with just one<br><br><img src=""paste-8a1f4ead1c185dc244d9366aea9d3749a2ff5115.jpg""><br>"
Describe <i>Any </i>and <i>AnyObject</i>"<br>- Not used so much now<br> -AnyObject - can only refer to a class<br>- Swift is strongly typed - in general you'll have to cast an object retrieved via one of these to an actual Type.<br><br><img src=""paste-d09801512750f962328eb4cfd0de43f848310ff8.jpg""><br>"
Describe casting"swift is trongly typed, sometimes you are able to cast one type as another, for example Array as NS array to get at the extended functinoality avaliable for NSArray<br><br><img src=""paste-39e69f27e79c90c1ffe947f6237c59528fa009f8.jpg"">"
Describe how closures work and name the 3 kinds-These are self contained blocks of code that can be passed around and used in your code.<br>- These can capture and store references to constants or variables from the context in which theyre defined<br><br>3 kinds include:<br><br>- global functions - have a name & cannot capture any values<br>- nested functions - have a name & can capture values from their enclosing functions<br>- closure expressions - don't have a name & can capture values from thier context
explain closure syntax"<img src=""paste-78bf586a2d6c08974962b0787b9e9302d32b0402.jpg""><br>- parameters can be in out <br>- we can potentially use a varaible number of arguments as long as they are named<br>- tuples can be used as parametes and as return types"
"explain a closure expressions example given:<br><br><img src=""paste-667605f9e69bed517f7ed6efe4af45a61a9a71f5.jpg"">""It returns a new sorted array of the same type and sieze as the input array (which itself isnt modified)<br><br>It accepts as a parameter, a closure that takes two arguments of the same type as the array's contents, and teh which returns a boolean indicating if item 1 > 2<br><br>Below is an example of closure where a string array is reverse sorted:<br><br><img src=""paste-34c47de79252a7631e45e8ae1d8e2de8347a79df.jpg""><br><br>Argument of type string and return type is a boolean, no ned to specify types above."
"example of trailing closure: reverse sort of a string array<br><br><img src=""paste-0f3e300c716808484e8c7a542d00292ee82eb182.jpg"">""<img src=""paste-925f8943378da2492fc1c434f8a62cd1aad5b81d.jpg""><br><br>If the closure is the only parameter to the method and it is provided as a trailing closure, then you don't need to write the pair of parentheses."
Describe how managing memory works in IOSAll OS's support some sort of memory management, allocating and freeing up memory for processes<br><br>- in the tightly constrained enviroment of the iphone, effiecient use of memory is essential<br>- this is traditionally done using some or garbage collection process it is a automated process which runs at vrious times to check which blocks can be deallocated and return them to a general pool, this typically involves tracing objects that are reachable vai a ste of roots objects.<br>- this frees the user from worrying about memory allocation but at a price as using garbage collection can be time consuming and require significant extra resoureces making other processes pausing (not good in middle for phone call for example)
What are the two approaches to managing memory used in IOSARC: automatic refrence counting<br>-  compiler evalues the requirements of your objects, and automatically inserts memory management calls at compile time.<br>- it is possible to have a situation where an instance never as zero strong references (cuuply resoures needlessly -> memory leak<br><br>MRR: Manual retain release<br>- Developer explicity inserts memory management calls (return and release into the cdoe)<br><br>Both use retain counts for each oject, in swift allocation and freeing of memory is automatic via ARC
How does reference counting work in memory management in IOS"Every allocated object has a retain count<br>- this is defined as NSObject<br>- as along as the count is >0 object is alove and valid<br>#- when objects are shared (owned by more than one variable) then the retain count should track this"
What does the Model do?Contains underlyin data<br>- could correspond to an external data source or soe current model<br><br>- Actions on the model manage the app data and its state<br><br>- not concerned with UI or presentation<br>Leave the interface to the view, and the application to the controller<br><br>- same model should be reusable, unchanged in different interfaces<br><br>- typically the is the most reusable component
What does the view do"This is what you see on the screen<br>- the canvas itself, and the interface elements such as buttons, labels, table views etc<br>- It allows user to manipulate data and displays data sent to it<br><br>Does not store any data <br>- Use the model to maintain data<br>- In certin circustanes it CAN ""store"" some data!<br>- Updataes to the model are done through the controller<br><br>Easily resuable and often configurable to display different data<br>- Often uses delegation to allow user to configure behaviour withou subclassing<br><br>TEnds to be reusable - especially if well written"
What does the controller do?"This is the glur that defines what your app does<br>- Knows about the view and the model<br>- Acts as an intermediary between them, when the model changes it lets the view knokw when and when data is manipulated by the view or other events are triggered it updates the model.<br><br>IOS includes several controller types tailored to managing their own views:<br>- UIViewController for managing apps with generic views<br>- UITabBarController for tabbed applications (e.g clock)<br>- UINavigationController for managing hierachal data (e.g email folders)<br>- UITableViewController for lists of data etc (e.g iTunes tracks)<br><br>Typically app sepcific and thus rarely reusable<br><br>Controller typically exposes outlets and actions which can be used by the model and view <br>- outlets allow your code to accces the ""value"" (and other aspects) of interface objects"
Why being lazy is good for performanceWhen the framework needs to render the views it determines which are visibile and on drawns those. For each view that should be redrawn, its draw() method will be called. This can signifcantly improve performance
what does draw() do?"func draw (_ rect: CGRect)<br>- UIView.draw() does nothinig by default <br>- If not overidden, then backgroundCOlor is used to fill the view<br>Override draw() to draw a custom view<br>- rect argument is are to draw<br><br>draw() is invoked automatically by the O/S<br>- Dont call it directly! Let the framework decide<br>- When the app thinks the view needs to be drdrawn, use: <br>sestNeedsDisplay()<br><br>For example in your controller<br><img src=""paste-059e65606da9a088225c444abe537668a334d91e.jpg"">"
what is the graphics context setup?"All drawing is done into a on opagque graphics context<br>- Normally setup autmatically, so no need to set this up explicitly<br><br>Graphics context setup automcatically before innvoking draw()<br>- Defines current path, line width, transform, etc.<br>- Access the graphics context within draw() e.g calling<br>- let context = UIGraphicsGetCurrentContext()<br>- Use CG calls to change the settings such as colour, line width etc.<br><br>Context only valid for the current call to draw()<br>- Do not cache a CG context<br><img src=""paste-27b29173adb5b102a1c32b70a1c7849361428e65.jpg"">"
What are IBOutlets?"These are properties of a view controller that are exposed to Storyboard.<br>- Objects are created in storyboard<br>- memory is allocated for these objects and they are automatically managed<br>- By ""linking"" objects in storybaord with properties of the view controller (known as the files owner), the controller takes control of those objects"
What are IBActions?They identify methods provided by a view controller that can be called when some action occurs within the interface<br><br>These are exposed to storyboard, and can be linked ot cations peformed by an interface object<br>- Events will be generated by an interface object<br>- Those events that are valid for the object can then be linked back to the IBAction exposed by the File's owner
How to programatically define the size and loction of view objects?"Views are intialised using UIView's intialiser method when the instance of the view is instantiated.<br><br><img src=""paste-ecbf31884e9ce71e2efe2ca430868d5a27a9f42b.jpg""><br><br>The size and location of view objects can of course be done in the storyboard "
viewDidLoad()?Control point to implement any additional logice after the view loading<br><br>You often implement it in your controller class (method stub supplied by deafult by Xcode)<br>- e.g to restore previously saved application state<br><br>At this point everything has been unarchived from the storyboard and all property connections have been made (outlets and actions)
What do scenes do?On iphone, it represents a screens worth of content. On iPad and Mac a screen can be composed of more than one scene ( or more than one window)
What is a segue?Manages the transitions between two scenes<br>& controls trigger the segues betewen scenes
What are controls?view objects that allow users to intiate some type of actions<br><br>Respond to a variety of events<br>- Touch events (touchDown, touchDraggered, touchUp)<br><br>- Value chagned<br><br>- Editing events (editing began, editing changed, editing ended)
quick rundown on how to pass data between views?"1. Declare a global variable<br>- In our 2nd view controller source we can access the globale variable<br><br>2. Pass a variable between ViewControllers<br>- In our 2nd viewcontroller class we declare the var (local to the class)<br>- In storyboard highlight a segue and ""name"" it, so we can identify it<br>- In the first view controller, in prepare (for segue) first check it's the correct segue and then set the desired variable in VC2 to teh value we want to pass."
What does UINavigationController do?"Provides a stack of controllers<br>- As the user explores the data in new views, corresponding controllers are pushed onto the stack<br>- When the user leavees tehse views, they are popped off the stack<br><br>A navigation bar suppoorts this navigation<br>- Includes a back button, title, edit buttons etc.<br><br><img src=""paste-2d63f5b12aee83737b3ff61466669daffa1bd331.jpg"">"
push and pop to add/remove a view controller?"<img src=""paste-ef13e237be62dc1e88fa00a0dbc6512bb5e1b50b.jpg"">"
What is a UITabBarController?"Provides an array of controllers<br>- User can select which view to inspect or interact with<br>- The selected view appreas in the main screen area<br>- The corresponding image appears in blue within a tab bar that appears at the bottom of the display<br><img src=""paste-2f3eedd7192216ff3ec2f32d3a7f06673b3ece2f.jpg""><br><br>When using a tab bar controller, the different controllers appear to be held in an array<br>- View controllers can deine their apperance in the tab bar<br>- each view controller comes with a tab bar item for customising <br><img src=""paste-1bd70f4c74671f5c7c783127d950f3b3be5d8a49.jpg"">"
What happens when a tab bar has too many view controllers to display at once?"""more"" tab bar item is displayed automatically<br>- User can navigate to remaining view controllers <br>- User can also customise what apperas on the tab bar<br><img src=""paste-3b0c379e0c1c047507e2edc4743e4b5ce805015d.jpg"">"
How would you combine tab bars and navigators?"Often it is desirable to include a navigation controller as one of the views from a tab<br>- first create the tab bar conntroller<br>- then create the navigation controllers<br>- finally, add them to the navigation controller<br><img src=""paste-cad360f254188baf0ecb0330c103a50b235318cb.jpg""><br>A common mistake is to make the tab bar controller the first view of the naviation controller<br>- this will simply disappear when the newxt view is pushed."
What are modal views?"Modal views temporarily interrupt the currrent workflow<br>- Often used to gather new data or present information<br>- Displaying preferences, such as displaying informaiton via a flip side information view<br>- Asking the user for specific information - such as creating a new contact in AddressBook<br>- Presending alerts (e.g with UIAlertView) or action sheets (UIActionSheet)<br><img src=""paste-ed2c58654a74e0b5d1024b6342e25bf9c2a4dc30.jpg""><br>Generally any view can be presented modally <br>- View remains until it is dismissed, at which point the application returns to its previous state"
steps to presenting a view controller modally?1. Create the view controller you want to present<br>2. Set the modalTransitionStyle property of the view controller<br>3. Assign a delegate object for the modal view controller<br>4. Call presentViewController (_ viewControllerToPresent: UIViewController, animated flag: Bool, comlpletion: (() -> Void) ? = nil) method of the controller parent, passing in the view controller child
What are the two ways modal views can apppear (IOS 14 or later)1. sheet<br>2. fullscreen
Best approach to dimissing a modal view controller and the advantages of this?best approach is to let the parent dismiss it's own child view controller<br>- normally handled through delegation, thus the object that presents the modal view controller becomes its delegate<br><br>- therefore the child viewcontroller must define a protocol for its delegate to implement, this defines actions the the delegate should do in response to certain actions<br><br>Advantages of doing it this way:<br>- Allows the parent to validate data before dismissing the child<br>- Promotes reuse, as the child view controller can be resued elsewhere
implementation of protocols?"a protocol is a list of methods, properties and other requirements that can be shared among classes<br>- there is no existing implementation of these methods in the protocol rather it is up to the developer to implement.<br><br>A class can choose to conform to or adopt a protocol<br>- conforming to more than one protocol is possibble<br>- informally similar to multiple inheritancez<br><br><img src=""paste-b7310625bb0203c59af185ef7ef8bfc8607c9d6b.jpg""><br><img src=""paste-2e1d382a6fcfbb9e7c30945c7e6427acc151c378.jpg""><br><img src=""paste-704641756bfcc9305f6152a73c9c14349947bdc4.jpg"">"
What are property lists and what are they good for & what not good for"property lists are structured data used by Foundation<br>- it provides suppport for primative data types & collections<br>- Root level object is alomsot always either an array or dictionary<br><br>property lists are a really good way to store small, structured persistent data fragments<br>Good for:<br>- Less than a few hundred kilobytes of data<br>- well defined dasta elements that fit the XML data serialisation<br><br>Bad for:<br>- large data volumes , loading is ""one shot""<br>- complex objects<br>- blocks of binary data"
What does UserDefaults do?"UserDefaults provides a ""registry "" for storing values<br>- Generated ona  per user / per applicaiotn basis<br>- register the different settings<br>determines the default values and types of the settings for first use, or if reset<br><img src=""paste-832c9e869438f4fe0b6169a96bd777bbd9f17d16.jpg""><br><br>UserDefaults can be set and retrived at any point in the application<br>- access the faults object and treat as a dictionary<br><img src=""paste-6278b803f638a858e6bb255ed137fdce73dc9009.jpg""><br>- Values are cached in the application and the OS periodically stores values to the defaults database.<br><br>UserDefaults is avalible across the range of Apple platforms<br>- The hwole databse can be cleared using UserDefaults.resetStandardUserDefaults()<br>-UserDefaults includes methods to return a specific type"
What is JSON (javascript object notation"Its a open standard file format that uses human readable text to transmit data objects <br>- language independent - originally from javascript<br>- supports: collections of objects, ordered list of arrays, values can be many data types<br>- elements can be nested<br><br>JSONSerialization class<br>- converts JSON data foundation objects<br>- converts foundation objects into JSON data<br>- see isValidJSONObject() for supported types<br><br>The JSON structure naturally matches that of the Swift types:<br>- dictionaries that contain key value pairs<br>- Arrays or Sets that contain lists of values<br><img src=""paste-5ac3b963e074ba279225e8ad7a1f56a872ec3be2.jpg"">"
Encoding and decoding using JSON (example)"<img src=""paste-62cf9f171c4ee8b8116d31da7a618e9cc7936f78.jpg"">"
What are archiving objects (serialisation)A serialisaiton of some  object graph that can be saved to disk<br>- and then be loaded later<br>- this is what is used by nibs/xibs/storyboard<br><br>Use the Encodable and Decodable protocols<br>- Use Codable prtocol for both<br><br>- declares two methods that a class must implement so that instances can be encoded or decodd<br><div>• Encode an object for an archiver: encode(to:)<br>• Decode an object from an archive: init(from:)<br></div>
What does core data do?Provides infrastructure for managing all the changes to your model objects<br>- includes automatic support for undo and redo<br><br>supports the management of subset of data in memory at any time<br>- good for managing memory and keeping footprint low<br><br>Uses a diagrammatic schema to describe your model objects and relationships<br>- supports default values and value validationo<br><br>Maintains disjoint sets of edits on your objects<br>- can allow the user to edit some of your objects whilst displaying them unchanged elsewhere
Managed object contexts?a context represents a single object space in an application<br>- Responsible for managing a collection of managed objects <br>(manged objects form a group of related model objects that represent an internally consistent view of a data store e.g records and their relationships<br><br>- Also responsible for:<br>complete life cycle management<br>validation of data<br>relaitonship maintenance<br>undo and redo actions<br><br>Instance of an NSManagedObjectContext<br>- or an NS Managed Obejct Context
How are managed objects exists within managed object context?"<img src=""paste-8d0b039aa123a7ebe1be308c808513f1ee78c86a.jpg"">"
What is the human computer interaction (HCI)?it cocnsiders the man machine interface, three basic concepts:<br>Humns: single or multiple users, with diverse abilities acting compeitively or cooperatively<br>Computers: different computing devices (not just PCs of course<br>Interaction: through commands or manipulating virtual objects, or via speech, gesture or touch<br>
How can interaction with machines be improved?- explicit interaction (eHCI)<br>- implicit interaction (iHCI)
What to poorly designed user interaces lead to?high training costs<br>- less intuitive interfaces require more time to learn or understand<br>- retraining may be required for different systems that otherwise do the same task<br><br>Higher usage costs (less efficiency)<br>- tasks take longer due to having to fight with the interface<br>- undermines users leaving them with no control<br>- can result in higher error rates<br><br>Ultimately lower adoption (and hence sales)<br>- unless the system is fit fo rpurpose and provies some value to the customer over the usage costs (both effort and financial) adoption will suffer<br><br>
How does a good design limit erors and makes them reoverable. HCI : errorsIf an error is possible someone will lmake it. The designer must assume that all possible errors will occur and design so as to minimise the chance of the error in the first place, or its effects once it gets made. Errors should be easy to detect, they should have minimal consequences, and if possible their effects should be reversible
Motivationo for human computer interaction (HCI)useful - accompmlishes the task required by the user<br>usable - does the taskk easily, naturally, safely, with low error rates<br>used: enriches the user experience
design adviceWhen designing a device or software you need to thinka bout how it will be used and in what enviroment<br><br>With anything complex, you need to decide what activities are the most important (and they should be the easiest to do - e.g the controls having a prominent position within a tv remote)
what is heckels law and his inverse law?The quality of the user interface of an applicance is relatively inimporntant in determining its adoption by users if the perceived applicance is high<br><br>Inverse law:<br>The importance of the suer interface design in the adoptin of an applicance is inversely proportional to the perceived value of the applicance<br><br>Whilst the usability of the interace is impornantce, the utility of the device ultiimately drives user adoption
What are the three qualities applications should have that Apple have stated themselves?Responsiveness<br>- Actions should lead to a direct result in a reasonable time<br><br>Permissiveness<br>- Users should be able to do anything which is reasonable<br><br>Consistency<br>- Mechanisms should be used in the same way wherever they may occur so that skills learned are transfereable
Goal of human computer interaction HCI?"to improve interaction between users and computers<br>- by making the devices more usable<br>- by making devices receptive to the ussres needs<br><br>Specifically, HCI is concerned with:
<br>• methodologies and processes for designing interfaces<br> • methods for implementing interfaces
<br>• techniques for evaluation and comparing interfaces<br> • developing new interfaces and interaction techniques
<br>• developing descriptive and predictive models and theories of interaction"
What is the difference between Explicit HCI(eHCI) and Implicit HCI (iHCI)?Explicit HCI (eHIC):<br>Concerned with the direct human interaction at set points during the devices normal operation<br>- typically ocntext free<br>- involves an explicit user model of the interface e.g turning on the light when walking into a dark room to retrieve object<br><br>Implicit HCI (iHCI):<br>The system responds to an act performd by the user, although the uesr act was not aimed at the system<br>- System has a model fof the user and their actions<br>- highly context dependent<br>- succeptible to noise e.g detecting a user walking towards a door and opening it for the user
adv and dis of PC WIMP interfaceThis is Windows, Icons, Menu and Pointer device<br><br>adv:<br>- order of commands or tasks can be much more ad goc<br>- use of direct manipulation lowers entry barrier for new users, fewer commands to be remembered<br><br>dis:<br>- not for visually impared<br>- consumers screen realestate <br>- visual representations may not alwys be clear to all users <br>- mouse control requires good hand eye coordination, can be slow to use<br>- larage number of virtual objects can be confusing and difficult to navigate.
Why do PC style WIMP interfaces not work on mobile devices?Display area is much smaller:<br>- impracitical to have several windows open on the display <br>- difficult to find and resize windows and icons stacked on one anoyher<br><br>Pointer/mouse metaphor usuited for mobile devices<br>- poinoter accuracy is reduced on small screens<br>- Lcak of a mouse requires other interaction modalities :cursor, scroll wheel, touch screen stylus
benefits of colour in design"Colour adds interest to an interface.
<br>• Human visual system has been “designed” by evolution to be able
to detect colour
<br>• Be aware that some people cannot see all colours (and some
cannot see *any* colour at all!).<br><br>Therefore:<br>- never use colour on its own to indicate something in an interface<br>- Use colour ot enhance an interface but consider those whose colour vision is incomplete "
Apples guidance to navigation<br><br>The different types "Hiearchial: Make one choice per screen until you reach a destination. To go to another destination,
you must retrace your steps or start over from the beginning and make different choices.
Settings and Mail use this navigation style<br><br><img src=""paste-4c22d4ba3916eff041836679c90d129a47cdcdf3.jpg""><br><br>Flat: Switch between multiple content categories. Music and app store use this naviagion<br><br><img src=""paste-a527506ec2fa4ff1fab5052ff33516c0aa72b146.jpg""><br><br>Content driven or experince driven: move freely through content or the content itself defines the navigation. Gmaes, books, and other immersive spps generally use this navaigation styels<br><img src=""paste-476f90ca1882828bb981ae622ef012faeb886ba2.jpg"">"
apples general guidance to navigation?"Always provide a clear path.
<br>• Design an information structure that makes it fast and easy to get to your app’s
content.<br> • Use touch gestures to create fluidity.
•<br> Use standard navigation components.<br> • Use a navigation bar to traverse a hierarchy of data.
<br>• Use a tab bar to present peer categories of content or functionality.<br> • Use a page control when you have multiple pages of the same type of content"
What is apples guidance ot page control?"- indicate the users posiiton amongst multiple ""pages"" e.g the weather at diffrent locations<br><br>- can customise the indicator image to enhace its meaning<br><br>- if a lot of pages are depicted, the controls at eithehr end are shrunk to indcate further pages<br><img src=""paste-30b8eee6d92ebd3da01967115f3a9d60b67f5e78.jpg"">"
Three questions when prototyping?"What needs to be more real?
<br>What can we fake?
<br>Where will they use it?<br><br>These questions should be different everything you show your app"
How to show and display basic design themes"through scetches#<br><br><img src=""paste-1be4b761c76bc587f2e1f8a5c746f5463351a509.jpg""><br><br>The three displays below are realistic copies of some of the displays above<br><img src=""paste-57e69522404e863e3e08cfcf9a63c83f69afbe95.jpg"">"
Why and how to prototype?"Why?:<br><br>Test ideas:<br>- save time and money building the right things<br><br>Get new ideas:<br>- make the experience of your app even better<br><br>How?<br>Make fake apps<br>to show them to people<br>learn from their feedback<br><br><img src=""paste-96e86f31af0eae26f61bf32e475f359ee102a9ab.jpg"">"
Cross platofrm deveopment?"Typically the native development system si well supported and a 3rd part one might not be<br><br>Crossplatform development enviroments are typically one of the following types:<br>- webbased<br>- cross complication<br>- run time engine<br><br>- Cross platform development is best suited to ""non standard apps""<br><br>- Often the interface elements are emulated, or have fewer opitons over native ones<br><br>- Access to core features of IOS may be reduced (e.g no core data - but Ios specific feature anyway<br><br>- Some platform specific code still required but majority of app code and logic applicable to all platforms<br><br>- very effective and can save money in development costs as you don't have to make new code for each platform"
Types of API'spublic <br>- avalible for third party use<br><br>private<br>- Not avalible for thrid party use, only for communcating between a app and the service, i.e ocado, hive, baking apps<br><br>agregate<br>- pulls together more than one API and returns one end point<br><br>Proxy<br>- sits between an API. particulary useful for failover, caching and high avaliability.
Why do apps take advantage of other companies of apps API;s typically talk to them via a proxy apiThis is done so you can cache responses (very impornant when the API has usage limits or fees), implement fails safes and switch data providers without having to push an update to you IOS app.<br><br>Also converts the data, modify the data and reduce the amount of data.
What is the language of API?"SOAP ""simple object access protocol"" . THis is used an XML payload known as an envelope<br><br><img src=""paste-07c6396794211cf501fd3caa803ac05704626d53.jpg"">"
typical JSON request"<img src=""paste-54d2508c6c0b6d479c22f942f2c8a87c5f5733bb.jpg"">"
Differences betwen hosting a server vs serverless (lambda)"<img src=""paste-adf9d4a30df5300ecb1e56a860b9e589aa080d2c.jpg"">"
What is tasks/async/await"This is concurrency<br>- does not use callback functions<br>- does not require use of dispatch queue<br>- reference / retrain cycles can be awaited with weak self or cancelling the task<br><img src=""paste-3156a6918b5216abd125218c1521281bc995272f.jpg"">"
What are solid state hall effect sensors?These are sensors that produce a voltage proportional to the applied agnetic field and alos sense plarity<br>- The movement of electrons is curved when a magnetic field is perpendicular to the direction of the charge through a conductor
What are accelerometers?"Measures the proper acceleration experienced relative to freefall<br> • Thus, at rest, it registers a 1g upward force along the vertical axis, but 0g during free
fall"
What is a gyroscope"Measures and maintains orientation, based on the principles of conservation of
angular momentum
<br>• Often used for games to provide rotational information and supplement accelerometers"
What are touchscreens"A display that detects the presence and location of a ""touch"" on a display<br><br>- typically a finger<br>- used in variety of settings<br>- until recently multi touch technology wasnt prevalent<br><br>Main tehcnologies based on resitive capacitive approaches<br>"
How has the touchscreen improved?multiple touch design<br><br>pressure based design<br>- two thin, metallica sperated electrically conductive layers<br>- pressure on the top layer produces a connection<br>- sensing the resistance across two, orthogonal directions detects position<br><br>High resolution <br>- suitable for both finger and sylus input<br>- supports multitouch
What is a capacitive touch screenIt is a touchscreen with electrostatic based design<br>- means it is an insulator (e.g glass) is coated witha  transparent conductor<br>- as humans are conductive, touch witha  finger creates a distortion in the elctrostatic field<br><br>Surface capaciatnce<br>- Uses only one coating. Durable but low resolution and is prone to false signals<br><br>Projected capacitance touch (PCT)<br>- conductive layer is etched as a grid<br>- permits a higer resolution than resistive approaches <br>- can also support multitouch<br>- used in all iphones 
adv and dis of voice input / automatic speech recognition?advantages:<br>- hands free access and control<br>- ability to control devices that have little or no other physical controls<br>- orthogonal input ot current intereaction acitivies; both with the device, and when performing other activites - such as driving<br><br>Disadvantages:<br>- often processor heavy<br>- susceptible to degredation in noisy environments<br>- speech may be recognised but not fully understood
What happens when you have multiple devices with voice recognitionThe devices communicate with each other by bluetooth to determine who is best to responsd<br><br>You can override this by waking a specific device, or pressing the button to use siri
Conclusion to automatic speech recognistion siri:"•Speech recognition of complex sentences requires lots of
processing power - initially this was only available in the
cloud
<br><br>• Modern devices have much more processing power -
designed for ML tasks (Apple’s “neural” engine). Possible to
have speech recognition done “on-device”.
<br><br>• iOS 15 supported some on-device Siri - limited to Timers &
alarms, phone, messaging, sharing, app launch, control
audio playback and (simple) settings."
What do context aware (CA) systems do?These are systems that can sense and react based on their enviroment.<br>Typically adapt their operation or gaol based on contextual cues from the enviroment or the users's actions<br>- implicit behvaiour, rather than explicitly directed by the user<br>- lessen the cognitive load on the user<br>- requires ability to  not only sense envioroment but to determine what is relevant to the systems tasks <br>
Context aware systems have human factors related context which are structed into 3 categories?:1. information on the user<br>e.g knowledge of habits <br><br>2. the users social enviroment<br>e.g co location of others / social interaction<br><br>3. the users tasks<br>e.g general goals they complete on their systems
Context aware systems have physical enviroment related context which are structed into 3 categories?:1. Location<br>e.g current position<br><br>2. infrasructure<br>e.g communcation, task performance<br><br>3. physical condiitons<br>e.g noise / light levels/ temp
What are the different ways of classifying context aware (CA) systems- proactive triggering<br>- streamlining interaction<br>- memories from the past<br>- reminders for future contexts<br>- optimising patterns of behaviour<br>- sharing experiences
What is the difference between passive and acitive context aware systemsPassive CA systems:<br>- new context is presented ot the user to inform them or change<br>- user can then explicitly determine if the user of applicaiton should change<br>examples include:<br>- phone status alerts<br><br>Active CA systems:<br>- behaviour o fthe applications change automatically<br>examples include<br>- video playback quality<br>- context based task activation
Context creation?"New context can be crated based on senor data (captured by the device iteself)<br><br>- lower level raw contexts may need to be processed into higher level contexts<br>raw data may need to scaled or transformed e.g signal on temperature gauge converted into celsius or fahrenheit value<br><br>Often this abstraction is more useful to the human e.g:<br>- this photo was taken on 2017-12-24 10:05:35 at lat 54.624062, long -1.636696”
<br> vs
<br>- “this photo was taken at my parents’ home last Christmas”"
disavantages of context awareness- enviromental cues may be inaccurate or erroneous<br>- the suer contexts may be incorrectly determined or predicted or just ambiguous<br>- lack of alignment with cues and the internal representation of context<br>- the use of contexts may reduce user privacy<br>- awareness of context shifts or changes in application may overload or distract the user
capabilities supporeed by discoverable devices?Abiltiy to :<br>- make other devies aware of its own existence and repsence <br>- advertise teh services it offeres and to provide additional informawtion when necessary<br>- dynamically serach and use other services<br><br>requires zero adminitatration<br><br>itneraction with other devices in the envirorment fulfils some goal
What doe suniversal plug and play allow devices to do?"- dynamically join a network and obtain an IP address
<br>- announce themselves and convey their capabilities upon request
<br>- learn about the presence and capabilities of other devices"
What are the different types of contexts that exist?- utility context<br>- locale context<br>- informative context<br>- productivity context<br>- immersive context
What is utility context?"most basic context<br>- simple task based scenarios<br>e.g calculator, weather forcast, unit conversion<br><br>- provides simple info<br>either by getching relevant info from a server or performing a simple calculation<br><br>Goal:<br>- provide info ""at a glance""<br>- focus on presenting only the relevant info unambigously<br>- avoids clutter (minimal aesthetic)"
What is a locale contextProminnent due to lcoation absed services<br><br>- provide information given the users position<br>tourist guides, location based social networks (uber)<br><br>- normally a map is presented with the location of items plotted<br><br>- odering is based on proxminity<br><br>- location of the user is impornant and should be emphasiesd (e.g pulsing blue dot)<br><br>
what is a informative context?Goal is to provide information such as a news site<br>- user wants to read or browse but not necessarily interact<br>- used during brief idel times, such as waiting for public transport<br>- need to rpovide the option to bookmarkk or save story to read later or flag favourites<br><br>Avoids having the user enter cmplex or length data so they can focus on the importance of the information (news story e.g)
what is a productivity context?Assists with heavier task based services<br><br>- User is focussed on performing a task rather than glacning or consuming information<br>- similar to using a tool on a desktop e.g managing email, contancts<br>- infomation often presented in a group or hierarchy format<br>^ should think how the user thinks about information (order and prioriy of tasks)<br>-e.g mail apps focus on inbox as a top priority item (yet sending email is still imporntant 
what is immersive context?this is immersive full screen applications<br>- media players, games etc<br><br>consume the users focus, by filling the enitre screen<br>- often includes augmented reality applications
What are schedules and what are the two types?Schedules hold many transactions for execution.<br>The operations making up the transactions are then executed by the schedule in some order<br>- it must preserve that the operations in each transaction happens in the right order!<br><br>There are two types:<br>Serial schedules: executes the transactions one after another.<br><br>Concurrent schedules: can interleave operations from the transactions in the schedule
How does a serial schedule work?A serial schedule exectues all operations in transaction T1, then all operations in transaction T2,<br><br>T1:<br>Begin (T1)<br>read(X);<br>X := X + 100;<br>write(X);<br>read(Y);<br>Y := Y + 50;<br>write(Y);<br>commit;<br>End (T1)<br><br>T2:<br>Begin (T1)<br>read(X);<br>X := X + 100;<br>write(X);<br>read(Y);<br>Y := Y + 50;<br>write(Y);<br>commit;<br>End (T1)
"What would be a shorthand schedule for a serial schedule using the example of its normal notation:<br><img src=""paste-59f4db44572ccf22970c112e722cefe4cbdafd1f.jpg"">""<img src=""paste-c12e00652653c0341142b1b28f7be583d98ae50f.jpg"">"
"<img src=""paste-0fdb4ac46231c47d4e47eaed5970308b5f370cd1.jpg""><br>what is the shorthand notation for this schedule?A""<img src=""paste-463c2c15e305c1a99b8fb49fb3d4a6b67cf3ba98.jpg"">"
What happens if there is is an abort or what happens if there is a commit in the atomicity stage?Abort:<br>an error prevented full execution<br>- we undo the work done up to the error point<br>- system recreates the databse state as it was before the start of the aborted transaction<br><br>Commit:<br>no eror, entire transaction executes<br>- the system is updated correctly
"What are the problems and solutions to those problems with this following turn of events?<br><img src=""paste-2b779ac6cc0579f7af3ec184d5d5b9b3a607d5c3.jpg""><br>User 1 has account 123<br>User 2 has account 456<br><br>This leaves user with £100 more than expected!"Problems:<br>1. There is an issue with how parts of the first transaction get executed<br>- a transaction should be atomic<br>2. There is an issue with how the two transactions interact:<br>- consistency issue as user 2 had £100 before user 1 has committed.<br>- The two transactions are not isolated from each other<br><br>Solutions:<br>- Do nothing bank would lose £100<br><br>- Undo the first transaction, but not the second. This could leave the second transaction invalid if there are insufficient funds:<br>This results from the isolation issue<br>This would give a consistency issue<br>- We could undo  both transactions. This would make the users confused as the state is not preserved<br>This is an issue as we expect that any change we make is durable
how does isolation work?A schedule that satisfies isolation if it is serializable <br><br>a schedule is serializable if it satisfies isolation
What are the different levels that SQL starndard divides isolation"1. Reaad uncommitted (no isolation) - it is fine if you read data which has not been committed<br>2. Read committed- everything you read must have been committed before you can see it<br>3. repeatable read - above and if you read the same twice in a transaction, you must get the same return value<br>Other transactions don't affect this transactions reads<br>4. Serilisable - above and a serial schedule i followed<br>Isolation level 4 is the default meaning of isolation, Some <br>some implementation have more levels<br><br>You can set isolation with the following statement:<br><img src=""paste-705ba73eba8e629bb59f5addd7e8a8047467852d.jpg"" width=""594""><br>TRANSACTION can also be set to READ ONLY"
what does the underscore do in swift?represents an unamed parameter / anomynous label which means we don't include it when we provide the parameter. There's a comma between parameters. 
navigation bar"- appears at the top of an app screen<br>- enables navigation through a series of hierarchical app screens<br>- when a new screen is displayed, it often has a back button, labelled with the title of the previous screen<br><br><img src=""paste-ec008bc5f20fbb5f1355363d9b1a6734658f584f.jpg"">"
Search bar?"used to earch through a large collection of values<br><br>- two styles: prominent and minimal<br><br>- contains a single search field that can include placeholder text a ""clear"" button etc<br><br><img src=""paste-d7050b24110d552516126836fe69def938078e4b.jpg"">"
Tab bar?"- Appears at the bottom of the screen<br><br>- provides ability to quickly switch between different app sections<br><br>- number of visible tabs varies depending on avaliable space<br><br>- A ""more"" tab can be displayed if not enough space for all tabs<br><br><img src=""paste-449fcb9fee0fd4efdf5d9377471e8adba78eb1cc.jpg"">"
Toolbar?"- appears at the bottom of the screen<br><br>- contains buttons for performing actions relevant to current view<br><br>- Icons or text tiltled buttons may be displayed depending on your requirements<br><br><img src=""paste-b58e57b6d287c696c288c754a18d154b19bfa531.jpg""><br>current view dosent change. tools operate on this view"
Action sheets"- specific style of alert - appears in response to a control or action<br><br>- presents two ore more choices relatedd to the current view<br><br>- Use them to let people initiate tasks, or request confirmation<br><br><img src=""paste-86b7cf834caf423227cd47467392a76005f6dc5e.jpg""> "
What is optional chaining?Optional chaining is where an attempt is made to access the optionals value, ut if it does not contain one then a nil is returned but the program does not crash<br><br>Example:<br><br>let numRooms = james.residence?.numberOfRooms<br><br>in this example the person may not have a residence and so if not they will not have a value for the number of rooms. In this case the reuslt will be an optional value
Describe how force unwrapping works"Is when the optinal is forced to provide a value by suffixing it with a ""!"". In the event that the optional does not contain a value, then the program will crash. <br><br>example:<br>let num = Int(""4567"")<br><br>in this example an int can be initialised from a string but this may lead to a nil if the string is not numeric. In this case we know that it is and so can force unwrap the result."
What are optional defaults?uses ??<br><br>one value or the other if it cant be either app will crash
Download