Swift Tutorial
[Link]
DevelopiOSAppsSwift/[Link]#//apple_ref/doc/uid/TP40015214-CH2-SW1
[Link]
[Link]
spritekit
[Link]
How to load image library
[Link]
%E7%94%A8%E8%80%85%E7%A7%81%E5%AF%86%E8%B3%87%E6%96%99%E9%83%BD
%E8%A6%81%E5%8A%A0%E4%B8%8Ausage-description-a01715e56491#.mznt3td5r
JavascriptCore
[Link]
Setup environment
Download Xcode
Build a Basic UI
Visual Presentation Code Remarks
1 Story board UIViewController Code in ViewController hook and control
the object in story board
2
App Delegate Source File
[Link] has 2 primary functions
Create the entry point to your app and run loop to delivers input event to your app.
Defines the AppDelegate class, the blue print for the app delegate object.
Predefine methods
1
func application(application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [NSObject: AnyObject]?) -> Bool
func applicationWillResignActive(application: UIApplication)
func applicationDidEnterBackground(application: UIApplication)
func applicationWillEnterForeground(application: UIApplication)
func applicationDidBecomeActive(application: UIApplication)
func applicationWillTerminate(application: UIApplication)
View Controller Source File
[Link]
Method
1 Func viewDidLoad()
Func didReceiveMemoryWarning()
Connect Outlets for UI Elements
1) Find the object in “Object library”. (View > Utilities > Show Object Library)
2) Drag the object to storyboard
3) Control+drag the object from storyboard to ViewController
Define an Action to Perform
iOS apps – event-driven programming (The flow of the app is determined by events: system
events and user actions).
An action (or an action method) is a piece of code that’s linked to an event that can occur in
your app
Understand the View Controller Lifecycle
To add image to your project
In project navigator, select [Link]
In the bottom left corner, click the “+”
Access photo library
如 access photo library 有這個問題” This app has crashed because it attempted to access privacy-
sensitive data without a usage description.”
可在 iOS 10 存取使用者私密資料都要加上 usage description
1) Go to XCode > app > Info
2) Click “+”, input “Privacy — Photo Library Usage Description”
Photo interactive
Allow Gesture Recognizer in photo can be interactive
1) Select the photo
2) In object library, select identity inspector
3) In accessibility, check “User Interaction Enabled”
Swift use javascript (JavascriptCore API)
JSVirturalMachine
Like a virtural machine
Has own heap and object
Cannot pass object between virtual machine
Has own main use case support concurrent access
No multi-thread
JSContext
An object represents the environment for executing javascript code.
Free to pass object between context.
JSValue
A primary data type
Can represent any javascript value
It is tired to JSContext
SpriteKit