Assignment 2
The purpose of this assignment is to write more advancediOSand Swift applications. The assignment consists of a programming task and a number of exercises that will be made available incrementally as milestones (so check the milestones inside this folder regularly to make sure you wont miss out on your next milestone!) Milestones are due every week and need to be submitted in or before the lab they are due in.
Some Hints
- Read the UI Testing documentation (also available directly from withinXcode) on how to record UI interactions for testing.
- Some nice hints on user interface testing can be found on the UI Testing Cheat Sheet !
- UseUIAlertControllerwithpreferredStyle: .ActionSheetto display action sheet alerts.
- UseWKWebView(orUIWebView) to display web content (you can load a web page through theloadRequest()method)! If you are using aUIWebView, make sure you set Allow Arbitrary Loads to YES for yourappunder AppTransport Security Settings in order to be able to load non-secure web pages!
- In order to useWKWebView, you need toimportWebKitin your project and link it against theWebKitframework!
- To create a URL request from a string, you can use theNSURLRequest(URL:)convenience initialiser, e.g.
-
- NSURLRequest(URL:NSURL(string:http://griffith.edu.au/)!)
- Saving data in property list format is easy, e.g. if you have an array of strings, you can save it using
-
- array.writeToFile(fileName, atomically:true)
- Loading such data back is equally easy, e.g. if you want to create a mutable array from the saved array above, use
-
- optionalArray=NSMutableArray(contentsOfFile:fileName);
- iOSuses a sandbox, so you can only load and save files from certain locations. E.g. if you want to save to a file calledplist, you can use
letdocumentsDirectory=NSSearchPathForDirectoriesInDomains(.DocumentDirectory,.UserDomainMask,true)[0]asNSString
letfileName=documentsDirectory.stringByAppendingPathComponent(data.plist)
- If the above does not seem to work for you for writing files, check that you have used.DocumentDirectoryand not .DocumentationDirectory(which is read-only this is a common mistake)!
- Core Data documents can be managed using the managedObjectContext property of UIManagedDocument
- The NSFetchedResultsController is a controller class that provides all the necessary methods you can use to update a table from a UITableViewController subclass!
- To convert an address to GPS coordinates forCoreLocation, you can use thegeocodeAddressString()function oftheCLGeocoder The function takes a trailing closure that passes in an array ofplace marks whose location you can pass to your map view.
- more hints to come check back regularly!
Reviews
There are no reviews yet.