Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Potato Hwang Object-C Mobile DEV sharing 130 Slides

1,646 views

Published on

iPhone / iPad Mobile DEV sharing 130 Slides from Potato Hwang

Overview:
1. iOS市場慨況介紹
2. 開發平台與開發方式介紹
3. (Mac+iPhone/iPad/模擬器)
4. 開發者帳號的申請與認識
5. 證書的申請與iOS Provisioning Portal 使用
6. 熟悉MacOS及Xcode安裝
7. 透過Xcode撰寫第一個程式
8. 實體手機上執行
9. iOS作業系統架構介紹
10. 協定Protocol
11. 分類Category
12. Block物件
13. 記憶體管理
14. UIDevice, UIApplication, UIScreen, UIWindow, UIView
15. 檔案存取.
16. SQLite 資料存取
17. UITable View

Enjoy it from Potato @ Taiwan Taipei, 烤蕃薯/烤芋頭

Published in: Technology
  • Be the first to comment

Potato Hwang Object-C Mobile DEV sharing 130 Slides

  1. 1. iPhone / iPad應用程式開發 分享 Potato Hwang @ Taipei Taiwan 2012 FB: 芋頭 http://www.facebook.com/potato888 Blogger: 蕃 http://gmi929.blogspot.tw/ E-mail: gmi929@gmail.com Potato Hwang @ Taiwan Taipei 2012 1Sunday, October 28, 12
  2. 2. INTRODUCE MYSELF 中文姓名: 黃于爵 英文姓名: Potato Hwang 學歷: 國立雲林科技大學 資 管理所 (碩)(畢) 2 Potato Hwang @ Taiwan Taipei 2012Sunday, October 28, 12
  3. 3. Potato’作品集 Potato Hwang @ Taiwan Taipei 2012 3Sunday, October 28, 12
  4. 4. Apple iOS 介紹 • iOS市場慨況介紹 • 開發平台與開發方式介紹  (Mac+iPhone/iPad/模擬器) • 開發者帳號的申請與認識 • 證書的申請與iOS  Provisioning  Portal  使用 • 熟悉MacOS及Xcode安裝 • 透過Xcode撰寫第一個程式 Potato Hwang @ Taiwan Taipei 2012 4Sunday, October 28, 12
  5. 5. iOS 6 Potato Hwang @ Taiwan Taipei 2012 5Sunday, October 28, 12
  6. 6. Potato Hwang @ Taiwan Taipei 2012 6Sunday, October 28, 12
  7. 7. Potato Hwang @ Taiwan Taipei 2012 7Sunday, October 28, 12
  8. 8. Potato Hwang @ Taiwan Taipei 2012 8Sunday, October 28, 12
  9. 9. Potato Hwang @ Taiwan Taipei 2012 9Sunday, October 28, 12
  10. 10. Potato Hwang @ Taiwan Taipei 2012 10Sunday, October 28, 12
  11. 11. Potato Hwang @ Taiwan Taipei 2012 11Sunday, October 28, 12
  12. 12. Potato Hwang @ Taiwan Taipei 2012 12Sunday, October 28, 12
  13. 13. Potato Hwang @ Taiwan Taipei 2012 13Sunday, October 28, 12
  14. 14. Potato Hwang @ Taiwan Taipei 2012 14Sunday, October 28, 12
  15. 15. Potato Hwang @ Taiwan Taipei 2012 15Sunday, October 28, 12
  16. 16. OSX Mountain Lion Potato Hwang @ Taiwan Taipei 2012 16Sunday, October 28, 12
  17. 17. iPhone/iPad程式開發流程 XCode& ( )& ( )& Potato Hwang @ Taiwan Taipei 2012 17Sunday, October 28, 12
  18. 18. iOS Developer Programs 個人/公司 皆可申請 必須公司才能申請 (可上架 App Store) (不可上架 App Store) Potato Hwang @ Taiwan Taipei 2012 18Sunday, October 28, 12
  19. 19. 三種發佈模式 • Ad Hoc (內) - 可安裝100部以內的設備透過iTunes即可, 不須經過App Store. • In-House (內) - 內部應用程式使用,可輕鬆安裝程式至大量機器上,且不須經過App Store • App Store (外)- 實際上架App Store - 正式申請Apple審核, 審核過關後即可上架至Apple Store 供人自由下載. Potato Hwang @ Taiwan Taipei 2012 19Sunday, October 28, 12
  20. 20. 證書(Certificate)申請(1/5) Step1:  ../Applications/Utilities/Keychain  Access Step2:  Keychain  Access  -­‐>  Certificate  Assistant                                            -­‐>  Request  a  Certificate  From  a  Certificate  Authority…                                        (鑰匙圈存取-­‐>憑證輔助程式-­‐>從憑證授權要求憑證) Potato Hwang @ Taiwan Taipei 2012 20Sunday, October 28, 12
  21. 21. 證書(Certificate)申請(2/5) Step4: Step3: Potato Hwang @ Taiwan Taipei 2012 21Sunday, October 28, 12
  22. 22. 證書(Certificate)申請(3/5) https://developer.apple.com/devcenter/ios/3 Potato Hwang @ Taiwan Taipei 2012 22Sunday, October 28, 12
  23. 23. 證書(Certificate)申請(4/5) https://developer.apple.com/ios/manage/overview/5 Potato Hwang @ Taiwan Taipei 2012 23Sunday, October 28, 12
  24. 24. 證書(Certificate)申請(5/5) Potato Hwang @ Taiwan Taipei 2012 24Sunday, October 28, 12
  25. 25. 新增設備 Potato Hwang @ Taiwan Taipei 2012 25Sunday, October 28, 12
  26. 26. 新增App ID ! ! Potato Hwang @ Taiwan Taipei 2012 26Sunday, October 28, 12
  27. 27. 描述檔 (Provisioning Profile)(1/2) App#ID# Local# #for#Dev# Potato Hwang @ Taiwan Taipei 2012 27Sunday, October 28, 12
  28. 28. 描述檔 (Provisioning Profile)(2/2) Local& &for&Distribution& & Potato Hwang @ Taiwan Taipei 2012 28Sunday, October 28, 12
  29. 29. 熟悉Mac  常用快捷鍵  (1/2) Potato Hwang @ Taiwan Taipei 2012 29Sunday, October 28, 12
  30. 30. 熟悉Mac  常用快捷鍵  (2/2) Potato Hwang @ Taiwan Taipei 2012 30Sunday, October 28, 12
  31. 31. XCode常用快捷鍵 快速搜尋: 將Project中具有相似名稱內容全部列出來! Potato Hwang @ Taiwan Taipei 2012 31Sunday, October 28, 12
  32. 32. 第二堂:  入門篇-­‐開發工具 • 認識Xcode • Hello World 1.0 使用XIB • Hello World 2.0 使用Storyboard • 修改圖示以及顯示名稱 • 在實體手機上執行 • iOS模擬器的使用 • Organizer的使用 Potato Hwang @ Taiwan Taipei 2012 32Sunday, October 28, 12
  33. 33. Hello  World  1.0  使用XIB Potato Hwang @ Taiwan Taipei 2012 33Sunday, October 28, 12
  34. 34. Hello  World  2.0  使用Storyboard Potato Hwang @ Taiwan Taipei 2012 34Sunday, October 28, 12
  35. 35. 第三堂:  Object  C  語言基礎 • iOS作業系統架構介紹 • 從C到 Object C • 選擇器與 息 • 輸出到主控台 • 類別 (Class) • #import 與@class • 變數的存取權限 • 建構子與解構子 Potato Hwang @ Taiwan Taipei 2012 35Sunday, October 28, 12
  36. 36. 類別(Class)-­‐暗黑3的五個角色(1/3) Potato Hwang @ Taiwan Taipei 2012 36Sunday, October 28, 12
  37. 37. 類別(Class),物件(Object),方法(Method)  (2/3) ! ! ! (Barbarian)! ! !(Attribute)! ! iation Instant :! ! ! :!10! (Demon!Hunter)! :!11! :!12! ! …! (Monk)! ! !(Method)! (Witch!Doctor)! +!(void)! !(Class!Method)! >!(void)! !(Instance!Method)! ! (Wizard)! >!(float)! (Instance!Method)! Note:! ! ! ! variable!( )! !Method!( )! Potato Hwang @ Taiwan Taipei 2012 37Sunday, October 28, 12
  38. 38. 訊息傳遞  (Message)  (3/3) ! ! Potato Hwang @ Taiwan Taipei 2012 38Sunday, October 28, 12
  39. 39. 類別(Class)的建立 @interface* (*.h)* @implementation* interface .** (*.m)* //ClassName.h* //ClassName.m* @interface*ClassName*:*ItsSuperclass*{* #import*“ClassName.h“* ******instance*variable*declarations* @implementation*ClassName* }* *******A(bool)*isEmpty{* ************return*self.count*==*0*?**YES*:*NO;** A*(bool)*isEmpry;* *******}* @end* @end* * * Potato Hwang @ Taiwan Taipei 2012 39Sunday, October 28, 12
  40. 40. 變數的存取權限 // Main() , data + @interfacc*Configuration:*NSObject* + + {* @public* , ******@public* .* (Default), ************NSDictionary**data;* @protected* .* ******@private* , @private* ************NSDictionary**filename;* .* }* @end* Potato Hwang @ Taiwan Taipei 2012 40Sunday, October 28, 12
  41. 41. #import  與@class // #Import) )(A.h)) // @class )(A.h)) #import(“B.h”( @class(B;( ( ( @interfacc(A({( @interfacc(A({( ((((((B(*b;( ((((((B(*b;( }( }( @end( @end( ( Potato Hwang @ Taiwan Taipei 2012 41Sunday, October 28, 12
  42. 42. Object  C  常用檔案類型 Potato Hwang @ Taiwan Taipei 2012 42Sunday, October 28, 12
  43. 43. 選擇器與訊息  (1/2) !""(void)""setName"":""(NSString"*)""input" " " " " " " " // setName " [self"setName":"input];" " " " " Potato Hwang @ Taiwan Taipei 2012 43Sunday, October 28, 12
  44. 44. 選擇器與訊息  (2/2) 2 2 2 2 2 //UIPickerViewDataSource2 2 32(NSInteger)pickerView:(UIPickerView2*)pickerView2numberOfRowsInComponent:(NSInteger)component2 2 2 2 2 2 2 2 // delegate , .2 // 2UIPicker2 2 [2pickerDelegate2pickerView:somePicker2numberOfRowInComponent:22]2 2 2 2 2 2 2 2 2 Potato Hwang @ Taiwan Taipei 2012 44Sunday, October 28, 12
  45. 45. 物件的概念  (object-­‐oriented)1/3 ! ! ! Potato Hwang @ Taiwan Taipei 2012 45Sunday, October 28, 12
  46. 46. 物件的概念  (object-­‐oriented)2/3 ! ! ! ! ! ! 80°C! 80°C! ! ! ! ! 1)  ! ! 2)  ! 3)  ! ! ! LED ! ! ! ! Potato Hwang @ Taiwan Taipei 2012 46Sunday, October 28, 12
  47. 47. 物件的概念  (object-­‐oriented)3/3 (Class)! ! ! ! 80°C! 80°C! ! ! ! ! ! 80°C! 80°C! ion! ! ! ntiat ! Insta ! ! ! LED! ! ! ! ! (null)! ! ! ! ! ! ! 80°C! 80°C! Instantiatio ! n! ! ! ! ! ! ! ! ! ! Instance!object! Potato Hwang @ Taiwan Taipei 2012 47Sunday, October 28, 12
  48. 48. 介面的概念  (Interface) ! ! ! ! ! ! ! ! Potato Hwang @ Taiwan Taipei 2012 48Sunday, October 28, 12
  49. 49. iOS作業系統架構介紹 , " , " Potato Hwang @ Taiwan Taipei 2012 49Sunday, October 28, 12
  50. 50. 第四堂:  Object  C  語言基礎 • 點運算子 • 協定Protocol • 分類Category • Block物件 • 例外補抓 • 例外拋出 • 資料類型 • 記憶體管理 Potato Hwang @ Taiwan Taipei 2012 50Sunday, October 28, 12
  51. 51. @property  ,  @synthesize 定義成員變數存取方式 Potato Hwang @ Taiwan Taipei 2012 51Sunday, October 28, 12
  52. 52. @property  ,  @synthesize Potato Hwang @ Taiwan Taipei 2012 52Sunday, October 28, 12
  53. 53. @property  ,  @synthesize Potato Hwang @ Taiwan Taipei 2012 53Sunday, October 28, 12
  54. 54. @property  ,  @synthesize • -nonatomic / atomic nonatomic -> 當 不需要使用 Thread時, 此方式Synthesize 出來的Code較快. - atomic -> 你可以想像他 synthesize 的 code 在存取時會用一個 lock 避免同時間有人存取。 • retain/copy/assign/weak (non-ARC使用) - retain, copy 都是說我對 個 property 有 ownership。 - weak 或 assign 則是我對此 property 沒有 ownership。例如 delegate 通常都用 weak/assign。 • strong / weak (ARC使用) - strong 算是新一代的宣示,他就是「我有 ownership」,至於細節怎麼處理,就是由 compiler ARC 去做了。 Potato Hwang @ Taiwan Taipei 2012 54Sunday, October 28, 12
  55. 55. 協定Protocol  (1/2) //MyClass.h @protocol drawing @interface  MyClass:NSObject  <drawing> @required @end - (void) paint; - (void) erase; @optional //MyClass.m -(void) outline; @implementation  MyClass   @end            -­‐(void)  paint{                }            -­‐(void)  erase{                } @end Potato Hwang @ Taiwan Taipei 2012 55Sunday, October 28, 12
  56. 56. 實作:  協定Protocol  (2/2)   :+ + FireBolt.h+ Enemy.h+ FireBolt.m+ Enemy.m+ + + // Protocol :+ + + // + @protocol+MagicDamage+ Name:+ + ++++++6(double)+getRate;+ Wizard.h+ Life:+ + @end+ ++(#import+"FireBolt.h")+ +++( : , )+ + Wizard.m+ // Protocol+ + 6(double)+getRate+ {+ ++++return+intelligence+*+ level;+ }+ Potato Hwang @ Taiwan Taipei 2012 56Sunday, October 28, 12
  57. 57. 分類Category  (1/2) @interface  NSString  (CheckEmpty)            -­‐  (bool)  isEmpry; @end @implementation  NSString  (CheckEmpty)            -­‐(bool)  isEmpty{                        return  self.count  ==  0  ?    YES  :  NO;                  } @end Potato Hwang @ Taiwan Taipei 2012 57Sunday, October 28, 12
  58. 58. 分類Category  (2/2) //=====類目的介面區段=====// @interface  Fraction  (MathOps)    //類別名稱為MathOps,類目裡所新增的方法未必要立即實做 -­‐(Fraction  *)  add:  (Fraction  *)  f;    //新增add方法:加法 -­‐(Fraction  *)  mul:  (Fraction  *)  f;    //新增mul方法:乘法 -­‐(Fraction  *)  sub:  (Fraction  *)  f;    //新增sub方法:減法 -­‐(Fraction  *)  div:  (Fraction  *)  f;    //新增div方法:除法 @end //=====類目的實做區段=====// @implementation  Fraction  (MathOps) -­‐(Fraction  *)  add:  (Fraction  *)  f{    ... } -­‐(Fraction  *)  sub:  (Fraction  *)  f{    ... } -­‐(Fraction  *)  mul:  (Fraction  *)  f{    ... } -­‐(Fraction  *)  div:  (Fraction  *)  f{    ... } Potato Hwang @ Taiwan Taipei 2012 58Sunday, October 28, 12
  59. 59. Block物件 - (void) testBlock { void (^swap) (int *, int*) = ^(int *x, int *y) { int z = * x; *x = *y; *y = z; }; int x = 100, y = 200; printf( “Before: x=%d, y=%dn”, x, y ); swap(&x, &y); printf( “Before: x=%d, y=%dn”, x, y ); } Potato Hwang @ Taiwan Taipei 2012 59Sunday, October 28, 12
  60. 60. 記憶體管理 (1/3) +1% +1% .1% .1% alloc%% retain% release% release% Potato Hwang @ Taiwan Taipei 2012 60Sunday, October 28, 12
  61. 61. 記憶體管理 (2/3) //弔詭範例 //正規保險範例 -­‐(id)  popArray  { -­‐(id)  popArray  {            id  lastObj  =  [array  lastObject]  ;            id  lastObj  =  [  [array  lastObject]  retain  ]  ;            [array  removeLastObject]  ;            [array  removeLastObject]  ;            return  lastObj  ;            return  [  lastObj  autorelease]  ; } } Potato Hwang @ Taiwan Taipei 2012 61Sunday, October 28, 12
  62. 62. 自動釋放 (NSAutoreleasePool) //  autorelease  範例 -­‐int  main  (int argc, char *argv[] ) {            NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]  ;            MyClass  *myClass  =  [[  MyClass  alloc]  init  autorelease]  ;            [myClass  testIt]  ;            [pool  release]  ; } Potato Hwang @ Taiwan Taipei 2012 62Sunday, October 28, 12
  63. 63. 記憶體管理 Q&A (3/3) Q1: What is the difference between copy and retain ? Potato Hwang @ Taiwan Taipei 2012 63Sunday, October 28, 12
  64. 64. 第五堂:  入門篇-­‐基本機制 • 四大重要類別 - UIDevice, UIApplication, UIScreen, UIWindow • 三大重要機制 - 代理機制與事件處理 - 息通知機制 - Target Action 機制 Potato Hwang @ Taiwan Taipei 2012 64Sunday, October 28, 12
  65. 65. 四大重要類別 • 設備本身 UIDevice • 應用程式本身 UIApplication • 手機螢幕 UIScreen • 主視窗 UIWindow Potato Hwang @ Taiwan Taipei 2012 65Sunday, October 28, 12
  66. 66. 設備本身UIDevice UIDevice *device = [UIDevice currentDevice]; 系統資 電池資 name 設備名稱 batteryMonitoringEnabled YES/NO 電池監控開關 systemName 作業系統名稱 systemVersion 作業系統版本 0.0 表示需充電, 1.0表示100%充滿了. (若 batteryLevel batteryMonitoringEnable為NO將回傳-1) model 設備型號 回傳電池狀態 localizedModel 設備型號(以本土化 息顯示) UIDeviceBatteryStateUnknown:未知狀態 batteryState UIDeviceBatteryStateUnplugged:電池未充電 UIDeviceBatteryStateCharging: 電池充電中 用來取得目前設備的界面形式,你可以透過 個屬性來取 UIDeviceBatteryStateFull: 電池100%充滿電了. userInterfaceIdiom 得目前設備是屬於iPad(UIUserInterfaceIdiomPad) / iPhone(UIUserInterfaceIdiomPhone) 距離感測器 (Proximity) uniqueIdentifier 取獨一無二的ID, But iOS 5 已經取消此功能. 回傳設備方向 proximityMonitoringEnabled YES/NO 開啟關閉距離感測器監控. UIDeviceOrientationUnknown: 未知方向 UIDeviceOrientationPortrait: 肖像模式 UIDeviceOrientationPortraitUpsideDown:上下顛倒肖像 YES/NO 用以表示距離感測器是否接近使用 orientation proximityState UIDeviceOrientationLandscapeLeft: 往左旋轉模式 者. (ex:應用判定設備是否靠近耳 .) UIDeviceOrientationLandscapeRight: 往右旋轉模式 UIDeviceOrientationFaceUp: 手機平放且面朝上 UIDeviceOrientationFaceDown: 手機平放且面朝下 Potato Hwang @ Taiwan Taipei 2012 66Sunday, October 28, 12
  67. 67. 應用程式 UIApplication UIApplication *app = [UIApplication sharedApplication]; 啟動搖晃 Undo功能 app.applicationSupportsShakeToEdit = YES; 取消自動睡眠 app.sharedApplication.idleTimeDisabled = YES; 狀態列控制 app.statusBarOrientation = UIInterfaceOrientationLandscapeRight; Switch(app.applicationState){ case UIApplicationStateActive: //喚醒狀態 break; case UIApplicationStateInactive: //睡眠狀態 取得應用程式狀態 break; case UIApplicationStateBackground: //背景狀態 break; default: } Potato Hwang @ Taiwan Taipei 2012 67Sunday, October 28, 12
  68. 68. 手機螢幕 UIScreen 取得螢幕物件方法 //取得所有連結到目前設備上的螢幕物件 NSArray *screens = [UIScreen screens]; //取得連結到設備上的主螢幕 UIScreen *screen = [UIScreen mainScreen]; 取得螢幕物件資 bounds: 用來表示整個螢幕大小(CGRect結構), (0,0,320 ,480高). applicationFrame: 同無(CGRect結構), 表示可顯示畫面的區域. 扣掉狀態列.(0,0,320,460). scale: 倍率. 設定螢幕明暗度 brightness: 介於0.0 ~ 1.0的浮點數,用來設定目前螢幕的明暗度. wantsSoftwareDimming: 設定是否允許使用軟體方式來將畫面調整的比實際硬體亮度還要暗. Potato Hwang @ Taiwan Taipei 2012 68Sunday, October 28, 12
  69. 69. 第六堂:  基本元件與事件處理 • 一切畫面元件的開始 UIView • 座標系統 • 子畫面的加入與移除 • 多點觸 事件的處理 • 具有圓角的UIView • 動畫效果 Potato Hwang @ Taiwan Taipei 2012 69Sunday, October 28, 12
  70. 70. Practice-保存期限 Potato Hwang @ Taiwan Taipei 2012 70Sunday, October 28, 12
  71. 71. View Controller Methods Potato Hwang @ Taiwan Taipei 2012 71Sunday, October 28, 12
  72. 72. 第七堂:  基本元件與事件處理 • GUI元件的使用 -對話盒的使用 - 動作清單元件 - 日期選擇元件 - 滾輪元件 - 活動狀態指示元件 - 進度狀態指示元件 - 標記的使用 Potato Hwang @ Taiwan Taipei 2012 72Sunday, October 28, 12
  73. 73. 對話盒元件 UIAlertView Potato Hwang @ Taiwan Taipei 2012 73Sunday, October 28, 12
  74. 74. 動作清單元件 UIActionSheet Potato Hwang @ Taiwan Taipei 2012 74Sunday, October 28, 12
  75. 75. 進度狀態指示元件 UIProgressView Potato Hwang @ Taiwan Taipei 2012 75Sunday, October 28, 12
  76. 76. 第八堂:  基本元件與事件處理 • GUI元件的使用 - 文字顯示元件 - 單行文字輸入元件 - 多行文字輸入元件 Potato Hwang @ Taiwan Taipei 2012 76Sunday, October 28, 12
  77. 77. 第九堂:  基本元件與事件處理 • GUI元件的使用 - 手勢辨識 - UIAppearance的使用 Potato Hwang @ Taiwan Taipei 2012 77Sunday, October 28, 12
  78. 78. 手勢辨識 • UITabGestureRecognizer: 輕拍 • UIPinchGestureRecognizer: 捏放 • UIRotationGestureRecognizer: 旋轉 • UISwipeGestureRecognizer: 掃過 • UIPanGestureRecognizer: 平移 • UILongPressGestureRecognizer: 長按 Potato Hwang @ Taiwan Taipei 2012 78Sunday, October 28, 12
  79. 79. UIAppearance的使用 一次改變某個元件的外觀. (ex:導航列) • Category • +appearance - 一次性的改變所有使用到某元件的外觀. • +appearanceWhenContainedIn - 條件性的設定,改變某元件外觀. Potato Hwang @ Taiwan Taipei 2012 79Sunday, October 28, 12
  80. 80. 第十堂:  基本元件與事件處理 • 畫面的管理 • 導覽列控制器 • 頁籤的使用 Potato Hwang @ Taiwan Taipei 2012 80Sunday, October 28, 12
  81. 81. 畫面的管理 (1/2) UIView賦予iOS畫面, UIViewController則帶給了 UIView生命! Potato Hwang @ Taiwan Taipei 2012 81Sunday, October 28, 12
  82. 82. 畫面的管理 (2/2) • 所有畫面都是以ViewController為單位. - 每一個畫面背後都有一個ViewController來控 制著畫面. Potato Hwang @ Taiwan Taipei 2012 82Sunday, October 28, 12
  83. 83. 導覽列控制器 UINavigationController Potato Hwang @ Taiwan Taipei 2012 83Sunday, October 28, 12
  84. 84. 頁籤控制器 UITabBarController Potato Hwang @ Taiwan Taipei 2012 84Sunday, October 28, 12
  85. 85. 第十一堂:  基本元件與事件處理 • 事件偵測, 晃動偵測 • 加速度計偵測 (應用範例: 水平儀) Potato Hwang @ Taiwan Taipei 2012 85Sunday, October 28, 12
  86. 86. 第十二堂:  基本元件與事件處理 • Undo/Redo 機制 • 認識Core Motion • 取得的資料 Potato Hwang @ Taiwan Taipei 2012 86Sunday, October 28, 12
  87. 87. Undo / Redo 機制 Potato Hwang @ Taiwan Taipei 2012 87Sunday, October 28, 12
  88. 88. 第十三堂:  進階篇-­‐資料存取 • 案路徑 • 案的存取 • 使用FMDB, 存取SQLite3資料庫 Potato Hwang @ Taiwan Taipei 2012 88Sunday, October 28, 12
  89. 89. Objective-C : Create NSArray // 方法一: Creates an NSArray with one object NSArray * myArray = [NSArray arrayWithObject:@"foo"]; // Creates an NSArray with multiple objects. Dont forget to add nil as the last object NSArray * myArray2 = [NSArray arrayWithObjects:@"foo",@"bar",@"baz",nil]; // Creates an NSArray from another NSArray NSArray * myArray3 = [NSArray arrayWithArray: myArray2]; // This will create an NSArray from data on iCodeBlog. Go ahead and try it out, this file exists on our servers and contains valid data. NSArray * myArray4 = [NSArray arrayWithContentsOfURL:[NSURL URLWithString:@"http:// icodeblog.com/uploads/foo.plist"]]; //方法二: NSArray * foo = [[NSArray alloc] initWithObjects:@"foo",@"bar",@"baz",nil]; Potato Hwang @ Taiwan Taipei 2012 89Sunday, October 28, 12
  90. 90. Objective-C : Access NSArray Potato Hwang @ Taiwan Taipei 2012 90Sunday, October 28, 12
  91. 91. Plist 檔案存取 Potato Hwang @ Taiwan Taipei 2012 91Sunday, October 28, 12
  92. 92. Using  SQLite Potato Hwang @ Taiwan Taipei 2012 92Sunday, October 28, 12
  93. 93. Using  SQLite  –  with  FMDB Potato Hwang @ Taiwan Taipei 2012 93Sunday, October 28, 12
  94. 94. 第十四堂:  進階篇-­‐表格元件 捲動的畫面  (UIScrollView) Potato Hwang @ Taiwan Taipei 2012 94Sunday, October 28, 12
  95. 95. 第十五堂:  進階篇-­‐表格元件 ! ! UITableViewStylePlain! UITableViewStyleGrouped! Potato Hwang @ Taiwan Taipei 2012 95Sunday, October 28, 12
  96. 96. UITableViewCell cell.imageView.image2 cell.textLabel.text=@”kkk2.jpg”2 cell.detailTextLabel.text=@”0.742MB,22009/7/142 12:52”2 cell.2accessoryType=UITableCellAccessoryDisclosurelndicator2 Potato Hwang @ Taiwan Taipei 2012 96Sunday, October 28, 12
  97. 97. 表格單元 - accessoryType Potato Hwang @ Taiwan Taipei 2012 97Sunday, October 28, 12
  98. 98. UITableView 結構 Potato Hwang @ Taiwan Taipei 2012 98Sunday, October 28, 12
  99. 99. 資料來源&事件代理 UITableViewCell,*cell,=,[[UITableViewCell,alloc],, ,initWithStyle:,UITableViewCellStyleSubtitle,, ,reuseIdentifier:,CellIdentifier];, Potato Hwang @ Taiwan Taipei 2012 99Sunday, October 28, 12
  100. 100. UITableVIew  結語: 當您在iPhone中設定一個表格,將會使用 UITableView 類別.但是 該類別並不知道表格名稱,包含多少區塊與欄位…etc.  所以必須定義一個稱 為UITableViewDataSource協定來解決這些問題.  (ex:當需要知道 在表格中每個區塊有多少欄位資訊時,它會依據協定呼叫已經在類別中定義 好的適當方法) UITableView類別也定義其它協定,如UITableViewDelegate.  此協定中 的方法除了定義其它的資料外,還定義當表格中某一特定欄位被選取的時候,所 要執行什麼動作.這個類別並不知道要採取什麼動作,所以由委派來負責.   Potato Hwang @ Taiwan Taipei 2012 100Sunday, October 28, 12
  101. 101. 第十六堂:  進階篇-­‐Core  Data • Entity-Relationship 模型 資料庫 Core Data 資料表 (Table) 實體 (Entity) • 使用多個表格 欄位 (Field) 屬性 (Attribute) • 條件式查詢 表格間的關聯 關係 (Relationship) 表:資料庫與Core Data 的對應 Potato Hwang @ Taiwan Taipei 2012 101Sunday, October 28, 12
  102. 102. 第十七堂:  進階篇-­‐聯絡人資 料的取得與顯示 • 聯絡人資料的存取 • 資 顯示 Potato Hwang @ Taiwan Taipei 2012 102Sunday, October 28, 12
  103. 103. 聯絡人資訊 • DataBase - AddressBook.sqlitedb - AddressBookImages.sqlitedb • File Path - 手機: /private/var/mobile/Library/AddressBook - 模擬器: ~/Library/Application Support/iPhone Simulator/User/Library/AddressBook Potato Hwang @ Taiwan Taipei 2012 103Sunday, October 28, 12
  104. 104. 資料欄位取得(1/3) (單筆記錄) 欄位名稱 說明 KABPersonFirstNameProperty 聯絡人 First name (名) KABPersonLastNameProperty 聯絡人 Last name (姓) ) KABPersonMiddleNameProperty 聯絡人 Middle name (中間名) KABPersonPrefixProperty 稱謂(如: Sir, Gereral...) KABPersonSuffixProperty 稱謂後綴 (如: Jr. Sr. ...) KABPersonNicknameProperty 綽號 KABPersonFirstNamePhoneticProperty First name的縮寫字母 KABPersonLastNamePhoneticProperty Last name的縮寫字母 KABPersonMiddleNamePhoneticProperty Middle name 的縮寫字母 KABPersonOrganizationProperty 組織名稱 KABPersonJobTitleProperty 個人職稱 KABPersonDepartmentProperty 部門 KABPersonBirthdayProperty 生日 KABPersonNoteProperty 解 KABPersonCreationDateProperty 聯絡人資料建立日期 KABPersonModificationDateProperty 聯絡人資料修改日期 Potato Hwang @ Taiwan Taipei 2012 104Sunday, October 28, 12
  105. 105. 資料欄位取得(2/3) (多筆記錄) 欄位名稱 說明 KABPersonEmailProperty Email 電話號碼 KABPersonPhoneProperty 個人首頁 KABPersonURLProperty KABPersonDateProperty 個人(紀念)日期 KABPersonAddressProperty 地址 KABPersonInstantMessageProperty 即時通 帳號 Potato Hwang @ Taiwan Taipei 2012 105Sunday, October 28, 12
  106. 106. 資料欄位取得(3/3) //  取得First  name欄位 CFStringRef  firstName  =  ABRecordCopyValue(record,  KABPersonFirstNameProperty); NSLog(@”First  name=  %@”  ,  firstName  ); //  取得電話  (多筆) CFTypeRef  theProperty  =  ABRecordCopyValue(record,  KABPersonPhoneProperty); NSArray  *phones  =  (__bridge_transfer  NSArray  *)                                                                                  ABMultiValueCopyArrayOfAllValues(theProperty); for  (NSString  *phone  in  phones)  {            NSLog(@”phone=%@”,  phone); } CFRelease(theProperty); Potato Hwang @ Taiwan Taipei 2012 106Sunday, October 28, 12
  107. 107. AddressBook.framework Potato Hwang @ Taiwan Taipei 2012 107Sunday, October 28, 12
  108. 108. 第十八堂:  實戰篇-­‐求籤App (1/2) • 起始畫面的製作 • 供品畫面的製作 • 求問畫面的製作 Potato Hwang @ Taiwan Taipei 2012 108Sunday, October 28, 12
  109. 109. 第十九堂:  實戰篇-­‐求籤App (2/2) • 求籤結果畫面的製作 • 畫面的串場 • 搖晃事件的處理 • 不透過Interface Builder產生畫面 Potato Hwang @ Taiwan Taipei 2012 109Sunday, October 28, 12
  110. 110. 第二十堂:  實戰篇 (產品審核與上架) • 編譯Ad-Hoc發 用的應用程式 • 專案上架 • 審核流程 • 兌換碼的使用 Potato Hwang @ Taiwan Taipei 2012 110Sunday, October 28, 12
  111. 111. 上架Apple Store 準備 Potato Hwang @ Taiwan Taipei 2012 111Sunday, October 28, 12
  112. 112. iOS Provisioning Portal Potato Hwang @ Taiwan Taipei 2012 112Sunday, October 28, 12
  113. 113. Code Signing 設定 Potato Hwang @ Taiwan Taipei 2012 113Sunday, October 28, 12
  114. 114. 上架 Apple Store Potato Hwang @ Taiwan Taipei 2012 114Sunday, October 28, 12
  115. 115. 上架 Apple Store 方法1: Application Loader 方法2: Organizer - Archives Potato Hwang @ Taiwan Taipei 2012 115Sunday, October 28, 12
  116. 116. iTune Connect http://itunesconnect.apple.com Potato Hwang @ Taiwan Taipei 2012 116Sunday, October 28, 12
  117. 117. iTunes Connect Manage Your Apps Potato Hwang @ Taiwan Taipei 2012 117Sunday, October 28, 12
  118. 118. Promo Codes 兌換碼(1/3) Potato Hwang @ Taiwan Taipei 2012 118Sunday, October 28, 12
  119. 119. Promo Codes 兌換碼(2/3) Potato Hwang @ Taiwan Taipei 2012 119Sunday, October 28, 12
  120. 120. Promo Codes 兌換碼(3/3) Potato Hwang @ Taiwan Taipei 2012 120Sunday, October 28, 12
  121. 121. Thank You ! Potato Hwang @ Taiwan Taipei 2012 121Sunday, October 28, 12
  122. 122. Misc. 雜項記錄 Potato Hwang @ Taipei Taiwan 2012Sunday, October 28, 12
  123. 123. Lesson  7:  UIImagePicker  (1/2) Single  Select Potato Hwang @ Taiwan Taipei 2012 123Sunday, October 28, 12
  124. 124. Lesson  8:  UIImagePicker  (1/2) Multi  Select Potato Hwang @ Taiwan Taipei 2012 124Sunday, October 28, 12
  125. 125. Lesson  9:  Save  Photo  to   Camera  roll Potato Hwang @ Taiwan Taipei 2012 Potato Hwang @ Taiwan Taipei 2012 125Sunday, October 28, 12
  126. 126. Lesson  9:  Save  Photo  (1/2) Potato Hwang @ Taiwan Taipei 2012 126Sunday, October 28, 12
  127. 127. Lesson  10:  Take  Photo  from   Camera Potato Hwang @ Taiwan Taipei 2012 Potato Hwang @ Taiwan Taipei 2012 127Sunday, October 28, 12
  128. 128. Lesson  10:  Take  a  Photo  from  Camera L7# L9# L10# Potato Hwang @ Taiwan Taipei 2012 128Sunday, October 28, 12
  129. 129. UIKit_Framework http://disanji.net/iOS_Doc/documentation/UIKit/Reference/UIKit_Framework/Art/ uikit_classes.jpg Potato Hwang @ Taiwan Taipei 2012 129Sunday, October 28, 12
  130. 130. Potato Hwang @ Taiwan Taipei 2012 130Sunday, October 28, 12
  131. 131. Thank You !Sunday, October 28, 12

×