Place to hold my solutions for the Hacking With Swift training series
- Table of Contents
- Project 1 - Storm Viewer
- Project 2 - Guess the Flag
- Project 3 - Social Media
- Project 4 - Easy Browser
- Project 5 - Word Scramble
- Project 6 - Auto Layout
- Project 7 - Whitehouse Petitions
- Project 8 - Swifty Words
- Project 9 - Grand Central Dispatch
- Project 10 - Names to Faces
- Project 11 - SpriteKit
- Project 12 - UserDefaults
- Project 13 - Instafilter
- Project 14 - What-a-Penguin
- Project 15 - Animation
- Project 16 - Javascript Injection
- Project 17 - Swifty Ninja
- Project 18 - Debugging
- Project 19 - Capital Cities
- Project 20 - Fireworks Night
- Project 20 - Fireworks Night
- Project 21 - Local Notifications
- Project 22 - Detect-a-Beacon
- Project 23 - Per-Pixel Collision Detection
- Project 24 - Swift Extensions
- Project 25 - multipeer connectivity
- Project 26 - Marble Maze
In this project we fix vertical spacing for project 2 so that it will work in landscape mode, and we learn how to programmatically add constraints to our UI
In this project we learned:
- How to use UITabBarController to reuse one interface design for multiple similar interfaces.
- Create a ViewController class that isn't in the storyboard, but just pushed onto the view in code.
In this project we learned:
- programmatically added a method to a button press with .addTarget()
- used
.enumerated()
on an array to get the element and the elements index as a tuple - Strings:
.index(of:)
- find index of element in array.joined(separator:)
- join array of String with "separator".replacingOccurencesOf()
- replace all occurrences of X with Y.forEach { $0.function() }
- to execute method on every object in array of objects
In this project we learned about Grand Central Dispatch (GCD). Specifically:
DispatchQueue.main.async { ...}
.performSelector(onMainThread:)
DispatchQueue.global(qos: .userInitiated).async { ... }
.performSelector(inBackground:)
Here we learned:
UIImagePcikerController
to pick an image from the camera roll- custom class (Person)
cellForItemAt
,numberOfItemsInSection
,didSelectItemAt
forUICollectionViewController
is very similar to the "ForRowAt" methods inUITableViewController
UIIImage(ContentsOfFile:)
to read in data as an image (like reading a file in as[String]
)UIImageJPEGRepresentation()
to convert a UIImage object to a Data objectData.write(to:)
to write data to a file in~/Documents/
Here we learned about SpriteKit. Specifically:
- SpriteKit
SKSpriteNode
SKAction
SKLabelNode
SKEmitterNode
- Good for mingling Swift with Objective-C
UserDefaults
NSKeyedArchiver
- Better if pure Swift
Codable
interfaceJSONEncoder
JSONDecoder
UISlider
kCIInputImageKey
kCIInputRadiusKey
kCIInputScaleKey
kCIInputCenterKey
kCIInputIntensityKey
CIImage
CGImage
CIFilter
CIBumpDistortion
UIImageWriteToSavedPhotosAlbum
- Info.plist -
Privacy - Photo Library Usage Description
- Info.plist -
Privacy - Photo Library Additions Usage Description
SKCropNode
SKTexture
SKAction
- GDD's
asyncAfter()
*.caf
sound files- check target membership in file inspector if it appears the file is inaccessible
- scale SKSpriteNode
UIView.animate()
- takes two closures- default animatons versus "spring" animations
CGAffineTransform
CGAffineTransform(scaleX: 2, y: 2)
to double the sizeCGAffineTransform.identity
to reset to originalCGAffineTransform(translationX: -256, y: -256)
to move the object up and to the left (negative number)CGAffineTransform(rotationAngle:CGFloat.pi)
- rotation angle in radians - 2*pi is 360 degrees in radians
imageView.alpha
- 0 to 1. 0 fully transparent, 1 fully opaque
- Safari Extension
ActionViewController
NSExtensionContext
NSItemProvider
loadItem(forTypeIdentifier: )
- In the Extension's
info.plist
:NSExtension
NSExtensionAttributes
NSExtensionActivationRule
NSExtensionActivationSupportsWebPageWithMaxCount
NSExtensionJavaScriptPreprocessingFile
NSDictionary
- adjust screen for on screen keyboard so you can see whole screen
NotificationCenter
UIKeyboardWillHide
UIKeyboardWillChangeFrame
UIKeyboardFrameEndUserInfoKey
view.convert
Notification.Name.UIKeyboardWillHide
UIEdgeInsets
UITextView.contentInset
SKShapeNode
AVAudioPlayer
UIBezierPath
- All about debugging.
print()
Assert()
- breakpoints
- conditional logic
- break on exception
- some debugging tooling around UIs
- Show View Frames
- Capture View Hierarchy
- MapKit
MKMapView
- protocols
- annotations
CLLocationCoordinate2D
MKAnnotation
- Customizing annotations
MKPinAnnotationView
canShowCallout()
Timer
object- More
SKNode
color
colorBlendFactor
SKAction.follow()
- how to detect the device being shaken
- Not the same thing as Push Notifications
- UNUserNotificationCenter
- DateComponents
- UNMutableNotificationContent
- UNNotificationSound
- UNNotificationAction
- UNNotificationCategory
- UNUserNotificationCenterDelegate
- UNNotificationDefaultActionIdentifier
- CLBeaconRegion
- CLLocationManager
- uuidgen
- CLProximity
- more SKEmitterNode, SKSpriteNode, and SKLabelNode
- per-pixel collision detection with
SKPhysicsBody
- just a playground this time.
MCSession
MCPeerID
MCadvertiserAssistant
MCBrowserViewController
UIImagePNGRepresentation
categoryBitMask
collisionBitMask
contactTestBitMask
linearDamping
- CMMotionManager
CoreMotion
- Compiler Directives
- #if
- #else
- #endif
SKPhysicsContactDelegate
didBegin()