MacOS App Coding Exercise
Download the project or run:
$ git clone https://github.com/ManuelBulos/PhotoBooth.git
Open photobooth.xcodeproj and hit run
After capturing a snapshot you'll be presented with the editing window:
When you are finished editing you can choose to save your work as .png or a .photobooth file. If you choose .photobooth you can open up that file again and keep editing (undoing previous lines and drawing new ones)
AVFoundation used for previewing computer's camera.
CoreGraphics used to handle path-based drawing
AEXML lightweight XML parsing. helps photobooth read polylines from svg files previously created using CGPoint arrays
The .photobooth extension is a UTI
Mac apps can add new uniform type identifiers for proprietary data formats. You declare new UTIs in the information property list (info.plist) file of a bundle.
This means that .photobooth is a directory (package) that contains 2 files:
- the image in a .png format
- the .svg file created from the CGPoints drawn inside the CGContext
This way we can open the png image, then parse the svg into an array of CGPoints and draw them again on top of that image.
I chose svg format because it's very easy to generate an XML file (SVG) from a given collection of CGPoints, we just need to map the x and y of each point to a polyline element on the XML File.
To run the unit tests just Open photobooth.xcodeproj and select the class photoboothTests in the photoboothTests.swift file
IMPORTANT NOTE: the test named "testSavingAndReadingFiles" prompts you with a window, so make sure to select a directory from there.
You can find more info about the project in the documentation