第一次程式親密接觸

187
ᒫӞ稞纷ୗ薥矑藉 彼得潘

Upload: -pan

Post on 24-Jan-2017

853 views

Category:

Mobile


2 download

TRANSCRIPT

彼得潘

https://www.youtube.com/watch?v=zLyhg-CZxiw

如果我會作詞作曲,我就能成為創作歌手。 我有一絲音感嗎?沒有。

所以,很可惜,我只能當歌手的朋友。

如果我有打不死的小宇宙,我就能成為桌球國手。 我有燃燒小宇宙般地練球嗎?沒有。

所以,很遺憾,我只能打系隊。

如果給我一天一個App的負荷,也澆不熄我對蘋果的熱情。

一天能夠完成一個App嗎? 可以。 所以,是的,我是愛瘋一切為蘋果的彼得潘。

彼得潘 :

: App App

Steve Jobs

https://www.youtube.com/watch?v=bQk7rdcl22o

App :iPhone.iPad

Swift

http://www.facebook.com/iphone.peterpan

http://deeploveapple.blogspot.tw

[email protected]

FB

blog

email

mediumhttps://medium.com/@apppeterpan

http://strikingly.us12.list-manage.com/subscribe?u=afa877b4a57124636b33826b0&id=4dd6b92dbb

http://apppeterpan.strikingly.com

? ?

Cocoa

?

: 100 0

ex 41. 2. 3. 4.

ex

1. 2. 3.

CPU

0 & 1

0 & 1

0 & 1

bit & byte

bit

8 bit byte

32-bit CPU & 64-bit CPU

10110000 ?

71 ?

302 302/2 = 151 0 151/2 = 75 1 75/2 = 37 1 37/2 = 18 1 18/2 = 9 0 9/2 = 4 1 4/2 = 2 0 2/2 = 1 0

1

100101110

10: a 11:b 12:c 13:d 14:e 15:f

c0de:

49374:

: 1100 0000 1101 1110

32-bit : f f f f f f f f

8-bit : f f 11111111 2 8 -1

unicode0 1

http://unicode-table.com

Swift

https://blog.alphacamp.co/2015/07/27/for-swift-beginners/

Swift• &

• ( javascript)

• App crash bug

• ( Objective-C )

• Playground

• Swift ( )

Swift•

• Open Source

• iOS SDK( SDK: App )

• Objective-C

• iOS 7

playground

Swift

• Mac ( ! )

• PC Mac ( )

• PC IBM Swift Sandbox Swift iOS App

http://swiftlang.ng.bluemix.net

CPU

Macbook Air / Pro

:

App

Mac Mini

: 15,900

iMac & Mac Pro

iMac: App

Mac Pro:

Mac XcodeApp StoreFree

Apple ID

https://itunes.apple.com/app/xcode/id497799835

Xcode playground Swift

playground

playground

1 2 9

" "

Emoji & Symbols

:

playground

var

age

Unicode

: function struct enum

!

var if for while …

reserved word

(constant)

18

let

variable & constant

• constant ?

• constant :

type

(Type Inference)

IntString

Double

Christie

http://www.ylib.com/hotsale/mystery_paperback/

! age Int

!

Debug Area

: Int String Double

Swift type

:

!

3

3

string interpolation ( )

string interpolation ( )

https://www.facebook.com/pages/ /205687452779322

string interpolation ( )

( )

https://www.youtube.com/watch?v=L-YMr0cTH6s

xxx xxx xxx ...

(1) :

(2) :

• :

• :

https://www.youtube.com/watch?v=wCREDfUEd3Y

if else switch

whilefor

https://www.youtube.com/watch?v=qA-TNQXcWiI

(if else)

https://www.youtube.com/watch?v=nFPIpTZJ1g8

https://www.youtube.com/watch?v=iOtETdw19GA

https://www.youtube.com/watch?v=Sy1TcpGsQcE

Bool ( true / false)

< <= >

>= == !=

else

nested if if

nested if if

else if

&&:

||:

https://www.youtube.com/watch?v=_o0oeyCtoFA

!:

var isRain = true

if !isRain { }

Ternary Operator ? :

var age = 20

var message = age > 18 ? "可以談戀愛":"認真讀書"

https://www.youtube.com/watch?v=fdSQ-R1drtg

var age = 35 var weight = 45 var height = 160 if age < 30 || weight < 50 && height < 170 { var message = " ()"

} else { var message = " " }

:

var age = 35 var weight = 45 var height = 160 if age < 30 || (weight < 50 && height < 170) { var message = " ( )" } else { var message = " " }

https://www.youtube.com/watch?v=NXhBcA_oZyY

message { }

message

if else

else if && ||

penny

http://mojim.com/twy105574x1x1.htm

if switch

- https://www.youtube.com/watch?v=M79Iq6c-b38

switchif else

switchif else

switch• case

case

switch• break

case

break

switch• case fallthrough

ex: 60 80 “ ”

switch• case

switch•

case let: value binding

var age = 10

switch age { case let ageNumber where ageNumber >= 18: var message = "\(ageNumber) 成年" default: var message = "未成年" }

var age = 10

switch age { case 100: var message = "\(age)" case let otherAge: var message = "\(otherAge)"

}

where

case var ok

• ” ” ” ” ” ”” ”

• ” ” ” ” ”” ” ” ”

• case let where 50 ” ”

40 ” ”” ”

https://www.youtube.com/watch?v=owk52BjC77U

1+2+31000

1000 ? !

: https://www.youtube.com/watch?v=uIWypArI73w

for

for

i = 1, i<= 1000i = 2, i<= 1000

i = 1000, i<= 1000 sum = sum + 1000

sum = sum + 1sum = sum + 2

i = 1001, i<= 1000

Graph

https://www.youtube.com/watch?v=3a_oa9CnVjs

Value History

Latest Value

佛曰:「受身無間者永遠不死,壽長乃無間地獄中之⼤劫。」

https://www.youtube.com/watch?v=VHJhwaqEJIs

infinite loop Apple

App

var sum = 0 for var i=0;i<=1000;i=i*10 { sum = sum + i }

https://www.youtube.com/watch?v=b5ANmLU9XL8

range

switch range

var grade = 30

switch grade { case 30: var message = "\(grade)" case 20...50: var message = "\(grade)" default: var message = "\(grade)" }

for in range

for in & where

while

repeat while:

loop

• 1 2 99

• : for

• : for in

• 2 4 100for & while ( )

for in & where

loop break continuebreak: loop

continue: iteration

var sum = 0 for var i=0;i<10;i++ { if i == 5 { continue } else if i == 6 { break } sum = sum + i }

:

: >=

function

function

func ( ) { }+ + +

function { }

function + ( )

function

function

function

:+ +

func addToNumber(number:Int){ var sum = 0 for var i=1;i<number;i++ { sum = sum + i } } addToNumber(100)

function

func addToNumber(startNumber:Int, endNumber:Int){ var sum = 0 for var i=startNumber;i<=endNumber;i++ { sum = sum + i } } addToNumber(10, endNumber: 100)

function

function external name & internal name

internal name: function

external name: function

external name ( )

700cc ?

functionfunc eatFood(food:String, price:Int) { } eatFood("chocolate", price:300)

function

function

Swift Standard Library Function function

print

https://www.youtube.com/watch?v=_sQSXwdtxlY

function 3

: 10, 20 3

10 + 13 + 16 + 19 = 58

function 3number 3 98 number 5

( 5 ) 5 + 10 + 15 + ..... + 95

function 3number 3 11 number 5

( 5 ) 3 + 4 + 6 + 7 + 8 + 9 + 11

:

function 2

: >=

function 2

https://www.facebook.com/miniHanaPreschool/

: class

.+ +

.+ + =+ +

n ( )

(method)

function { }

( )

( .+ + )+ + +

( ):

( ):

• method App

• iOS SDK

App

function

function

array

100

100

array

[ ] , 0

!Array index out of range

array

https://www.youtube.com/watch?v=ZSWeurc1yMw

array

append:

insert:

array struct struct

array

array

array for

array for

array for in

2

5 array

1. for in

2. array ( array )

for in

class Student { var grade = 60 var name = "peter" }

var student1 = Student() var student2 = Student() student2.grade = 80 student2.name = "Jack" var student3 = Student() student3.grade = 90 student3.name = "penny"

var students = [student1, student2, student3]

var maxGrade = 0 var maxName = "" var sum = 0 for student in students { sum = sum + student.grade if student.grade > maxGrade { maxGrade = student.grade maxName = student.name } } maxGrade maxName var average = sum/students.count

array

dictionary

array

dictionary

nil :

key ( ) value (

dictionary

App

App

• , Model

• : ,

••••••

https://www.youtube.com/watch?v=xr5JQdcqWyM

http://apppeterpan.strikingly.com

App• free vs. 0.99

100

• in-app purchase

••

•• App

App: 3

PTT App:

https://www.youtube.com/watch?v=_iC8jnx32ho

• App , , PM, Server ,

• App +

• App + App +

ios/Android(Windows)PHP/RoR/Python/ASP/Node.js

HTML / CSS/ JavaScript

photoshop/ illustrator/ sketch

Wealthy

!

App

mini.Hana Penny V.Khttps://www.youtube.com/watch?v=snRaHXpS3uI

iOS App : iOS App : 8 App iOS App : Collection View iOS App : iOS 9 Stack View iOS App : Facebook iOS App : iOS App : App

Auto Layout & Adaptive Layout 2016/2/20( )

App 2016/3/6( )

Apple Watch 2016/3/27( )

Apple TV 2016/5/28( )

IOS APP

42 iOS App ( 2

iOS App 42( 1

iOS App 42( 1

iOS App 35(

iOS App 35(

https://www.facebook.com/iphone.peterpan/