SlideShare une entreprise Scribd logo
1  sur  131
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        1
Sunday, October 28, 12
INTRODUCE MYSELF
                         中文姓名: 黃于爵

                         英文姓名: Potato Hwang



                         學歷:

                         國立雲林科技大學

                         
   資 管理所 (碩)(畢)


                                                     2

                                       Potato Hwang @ Taiwan Taipei 2012
Sunday, October 28, 12
Potato’作品集




                           Potato Hwang @ Taiwan Taipei 2012   3
Sunday, October 28, 12
Apple	
 iOS	
 介紹
                    •    iOS市場慨況介紹

                    •    開發平台與開發方式介紹	
  (Mac+iPhone/iPad/模擬器)
                    •    開發者帳號的申請與認識

                    •    證書的申請與iOS	
  Provisioning	
  Portal	
  使用

                    •    熟悉MacOS及Xcode安裝

                    •    透過Xcode撰寫第一個程式



                                      Potato Hwang @ Taiwan Taipei 2012   4
Sunday, October 28, 12
iOS	
 6




                         Potato Hwang @ Taiwan Taipei 2012   5
Sunday, October 28, 12
Potato Hwang @ Taiwan Taipei 2012   6
Sunday, October 28, 12
Potato Hwang @ Taiwan Taipei 2012   7
Sunday, October 28, 12
Potato Hwang @ Taiwan Taipei 2012   8
Sunday, October 28, 12
Potato Hwang @ Taiwan Taipei 2012   9
Sunday, October 28, 12
Potato Hwang @ Taiwan Taipei 2012   10
Sunday, October 28, 12
Potato Hwang @ Taiwan Taipei 2012   11
Sunday, October 28, 12
Potato Hwang @ Taiwan Taipei 2012   12
Sunday, October 28, 12
Potato Hwang @ Taiwan Taipei 2012   13
Sunday, October 28, 12
Potato Hwang @ Taiwan Taipei 2012   14
Sunday, October 28, 12
Potato Hwang @ Taiwan Taipei 2012   15
Sunday, October 28, 12
OSX	
 Mountain	
 Lion




                              Potato Hwang @ Taiwan Taipei 2012   16
Sunday, October 28, 12
iPhone/iPad程式開發流程


                         XCode&




                                                                (     )&
                                            (   )&




                                  Potato Hwang @ Taiwan Taipei 2012        17
Sunday, October 28, 12
iOS	
 Developer	
 Programs
                         個人/公司 皆可申請                                              必須公司才能申請




                           (可上架 App Store)                                       (不可上架 App Store)




                                             Potato Hwang @ Taiwan Taipei 2012                      18
Sunday, October 28, 12
三種發佈模式
                    •    Ad Hoc (內)
                         -   可安裝100部以內的設備透過iTunes即可, 不須經過App Store.


                    •    In-House (內)
                         -   內部應用程式使用,可輕鬆安裝程式至大量機器上,且不須經過App Store


                    •    App Store (外)- 實際上架App Store
                         -   正式申請Apple審核, 審核過關後即可上架至Apple Store 供人自由下載.




                                        Potato Hwang @ Taiwan Taipei 2012   19
Sunday, October 28, 12
證書(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                20
Sunday, October 28, 12
證書(Certificate)申請(2/5)
                                                         Step4:    '




                  Step3:'          '



                               Potato Hwang @ Taiwan Taipei 2012       21
Sunday, October 28, 12
證書(Certificate)申請(3/5)




                            https://developer.apple.com/devcenter/ios/3
                                     Potato Hwang @ Taiwan Taipei 2012    22
Sunday, October 28, 12
證書(Certificate)申請(4/5)




                           https://developer.apple.com/ios/manage/overview/5


                                      Potato Hwang @ Taiwan Taipei 2012        23
Sunday, October 28, 12
證書(Certificate)申請(5/5)




                               Potato Hwang @ Taiwan Taipei 2012   24
Sunday, October 28, 12
新增設備




                         Potato Hwang @ Taiwan Taipei 2012   25
Sunday, October 28, 12
新增App	
 ID
                                                              !
                                                                  !




                          Potato Hwang @ Taiwan Taipei 2012           26
Sunday, October 28, 12
描述檔
                         (Provisioning	
 Profile)(1/2)


                                                                     App#ID#
                                                                   Local#   #for#Dev#




                               Potato Hwang @ Taiwan Taipei 2012                        27
Sunday, October 28, 12
描述檔
                         (Provisioning	
 Profile)(2/2)




                                                            Local& &for&Distribution&   &



                               Potato Hwang @ Taiwan Taipei 2012                            28
Sunday, October 28, 12
熟悉Mac	
  常用快捷鍵	
  (1/2)




                         Potato Hwang @ Taiwan Taipei 2012   29
Sunday, October 28, 12
熟悉Mac	
  常用快捷鍵	
  (2/2)




                         Potato Hwang @ Taiwan Taipei 2012   30
Sunday, October 28, 12
XCode常用快捷鍵




                                                               快速搜尋:
                                                               將Project中具有相似名稱內容全部列出來!




                           Potato Hwang @ Taiwan Taipei 2012                             31
Sunday, October 28, 12
第二堂:	
  入門篇-­‐開發工具
                    •    認識Xcode

                    •    Hello World 1.0 使用XIB

                    •    Hello World 2.0 使用Storyboard

                    •    修改圖示以及顯示名稱

                    •    在實體手機上執行

                    •    iOS模擬器的使用

                    •    Organizer的使用

                                    Potato Hwang @ Taiwan Taipei 2012   32
Sunday, October 28, 12
Hello	
  World	
  1.0	
  使用XIB




                                  Potato Hwang @ Taiwan Taipei 2012   33
Sunday, October 28, 12
Hello	
  World	
  2.0	
  使用Storyboard




                               Potato Hwang @ Taiwan Taipei 2012   34
Sunday, October 28, 12
第三堂:	
  Object	
  C	
  語言基礎
                    •    iOS作業系統架構介紹
                    •    從C到 Object C
                    •    選擇器與     息
                    •    輸出到主控台
                    •    類別 (Class)
                    •    #import 與@class
                    •    變數的存取權限
                    •    建構子與解構子

                                      Potato Hwang @ Taiwan Taipei 2012   35
Sunday, October 28, 12
類別(Class)-­‐暗黑3的五個角色(1/3)




                         Potato Hwang @ Taiwan Taipei 2012   36
Sunday, October 28, 12
類別(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                                                    37
Sunday, October 28, 12
訊息傳遞	
  (Message)	
  (3/3)

                           !     !




                                 Potato Hwang @ Taiwan Taipei 2012   38
Sunday, October 28, 12
類別(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                                           39
Sunday, October 28, 12
變數的存取權限
              //     Main()   ,   data        +

              @interfacc*Configuration:*NSObject*                       +          +
              {*                                           @public*                         ,

              ******@public*                                                 .*
                                                                                            (Default),
              ************NSDictionary**data;*             @protected*
                                                                                  .*
              ******@private*
                                                                                       ,
                                                           @private*
              ************NSDictionary**filename;*                                      .*

              }*
              @end*




                                         Potato Hwang @ Taiwan Taipei 2012                               40
Sunday, October 28, 12
#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             41
Sunday, October 28, 12
Object	
  C	
  常用檔案類型




                               Potato Hwang @ Taiwan Taipei 2012   42
Sunday, October 28, 12
選擇器與訊息	
  (1/2)

                         !""(void)""setName"":""(NSString"*)""input"
                         "
                                    "               "                               "   "
                                                                                "       "


                         //   setName   "

                         [self"setName":"input];"
                         "
                                "              "           "




                                            Potato Hwang @ Taiwan Taipei 2012               43
Sunday, October 28, 12
選擇器與訊息	
  (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                               44
Sunday, October 28, 12
物件的概念	
  (object-­‐oriented)1/3
                                                 !
                                                                   !




                                                                       !




                               Potato Hwang @ Taiwan Taipei 2012           45
Sunday, October 28, 12
物件的概念	
  (object-­‐oriented)2/3
                                                                                                   !
                                               !
                                                                                                                           !
                                                                                       !                   !                       !
                                                                               80°C!               80°C!
                                       !

                                               !                                                                   !
                                                                                           !
                                 1)        !
                         !       2)                !
                                 3)                !
                                                                                               !               !


                                                   LED             !
                                                                                                                       !
                                                                                                                               !
                             !


                                                       Potato Hwang @ Taiwan Taipei 2012                                               46
Sunday, October 28, 12
物件的概念	
  (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                                                  47
Sunday, October 28, 12
介面的概念	
  (Interface)

                                                                              !
                                                                      !
                          !                                           !


                                                                          !
                          !                                               !



                              !




                                  Potato Hwang @ Taiwan Taipei 2012               48
Sunday, October 28, 12
iOS作業系統架構介紹


                         ,           "




                             ,   "




                                         Potato Hwang @ Taiwan Taipei 2012   49
Sunday, October 28, 12
第四堂:	
  Object	
  C	
  語言基礎
                    •    點運算子
                    •    協定Protocol
                    •    分類Category
                    •    Block物件
                    •    例外補抓
                    •    例外拋出
                    •    資料類型
                    •    記憶體管理


                                   Potato Hwang @ Taiwan Taipei 2012   50
Sunday, October 28, 12
@property	
  ,	
  @synthesize
                         定義成員變數存取方式




                             Potato Hwang @ Taiwan Taipei 2012   51
Sunday, October 28, 12
@property	
  ,	
  @synthesize




                             Potato Hwang @ Taiwan Taipei 2012   52
Sunday, October 28, 12
@property	
  ,	
  @synthesize




                             Potato Hwang @ Taiwan Taipei 2012   53
Sunday, October 28, 12
@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                     54
Sunday, October 28, 12
協定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                                55
Sunday, October 28, 12
實作:	
  協定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                      56
Sunday, October 28, 12
分類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   57
Sunday, October 28, 12
分類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   58
Sunday, October 28, 12
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   59
Sunday, October 28, 12
記憶體管理	
 (1/3)




                              +1%         +1%                  .1%               .1%
                         alloc%%    retain%             release%          release%




                                      Potato Hwang @ Taiwan Taipei 2012                60
Sunday, October 28, 12
記憶體管理	
 (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                                                                                61
Sunday, October 28, 12
自動釋放
                                  (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                             62
Sunday, October 28, 12
記憶體管理	
 	
 Q&A	
 (3/3)
                         Q1:	
 What	
 is	
 the	
 difference	
 between	
 
                         copy	
 and	
 retain	
 ?	
 




                                        Potato Hwang @ Taiwan Taipei 2012   63
Sunday, October 28, 12
第五堂:	
  入門篇-­‐基本機制
                    •    四大重要類別

                         -   UIDevice, UIApplication, UIScreen, UIWindow
                    •    三大重要機制

                         -   代理機制與事件處理

                         -     息通知機制

                         -   Target Action 機制


                                       Potato Hwang @ Taiwan Taipei 2012   64
Sunday, October 28, 12
四大重要類別
                    •    設備本身 UIDevice

                    •    應用程式本身 UIApplication

                    •    手機螢幕 UIScreen

                    •    主視窗 UIWindow




                                  Potato Hwang @ Taiwan Taipei 2012   65
Sunday, October 28, 12
設備本身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                                                   66
Sunday, October 28, 12
應用程式	
 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                                          67
Sunday, October 28, 12
手機螢幕	
 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     68
Sunday, October 28, 12
第六堂:	
  基本元件與事件處理
                    •    一切畫面元件的開始 UIView

                    •    座標系統

                    •    子畫面的加入與移除

                    •    多點觸   事件的處理

                    •    具有圓角的UIView

                    •    動畫效果

                                Potato Hwang @ Taiwan Taipei 2012   69
Sunday, October 28, 12
Practice-保存期限




                            Potato Hwang @ Taiwan Taipei 2012   70
Sunday, October 28, 12
View	
 Controller	
 Methods




                                 Potato Hwang @ Taiwan Taipei 2012   71
Sunday, October 28, 12
第七堂:	
  基本元件與事件處理
                    •    GUI元件的使用
                         -對話盒的使用
                         -   動作清單元件
                         -   日期選擇元件
                         -   滾輪元件
                         -   活動狀態指示元件
                         -   進度狀態指示元件
                         -   標記的使用


                                 Potato Hwang @ Taiwan Taipei 2012   72
Sunday, October 28, 12
對話盒元件
                          UIAlertView




                         Potato Hwang @ Taiwan Taipei 2012   73
Sunday, October 28, 12
動作清單元件
                          UIActionSheet




                          Potato Hwang @ Taiwan Taipei 2012   74
Sunday, October 28, 12
進度狀態指示元件
                          UIProgressView




                           Potato Hwang @ Taiwan Taipei 2012   75
Sunday, October 28, 12
第八堂:	
  基本元件與事件處理
                    •    GUI元件的使用

                         -   文字顯示元件

                         -   單行文字輸入元件

                         -   多行文字輸入元件




                                 Potato Hwang @ Taiwan Taipei 2012   76
Sunday, October 28, 12
第九堂:	
  基本元件與事件處理
                    •    GUI元件的使用

                         -   手勢辨識

                         -   UIAppearance的使用




                                     Potato Hwang @ Taiwan Taipei 2012   77
Sunday, October 28, 12
手勢辨識
                    •    UITabGestureRecognizer: 輕拍

                    •    UIPinchGestureRecognizer: 捏放

                    •    UIRotationGestureRecognizer: 旋轉

                    •    UISwipeGestureRecognizer: 掃過

                    •    UIPanGestureRecognizer: 平移

                    •    UILongPressGestureRecognizer: 長按

                                    Potato Hwang @ Taiwan Taipei 2012   78
Sunday, October 28, 12
UIAppearance的使用
                         一次改變某個元件的外觀. (ex:導航列)

                •        Category

                •        +appearance

                         -   一次性的改變所有使用到某元件的外觀.

                •        +appearanceWhenContainedIn

                         -   條件性的設定,改變某元件外觀.


                                       Potato Hwang @ Taiwan Taipei 2012   79
Sunday, October 28, 12
第十堂:	
  基本元件與事件處理
                    •    畫面的管理

                    •    導覽列控制器

                    •    頁籤的使用




                                 Potato Hwang @ Taiwan Taipei 2012   80
Sunday, October 28, 12
畫面的管理	
 (1/2)


                         UIView賦予iOS畫面, UIViewController則帶給了
                         UIView生命!




                                     Potato Hwang @ Taiwan Taipei 2012   81
Sunday, October 28, 12
畫面的管理	
 (2/2)


                    •    所有畫面都是以ViewController為單位.

                         -   每一個畫面背後都有一個ViewController來控
                             制著畫面.




                                     Potato Hwang @ Taiwan Taipei 2012   82
Sunday, October 28, 12
導覽列控制器
                         UINavigationController




                             Potato Hwang @ Taiwan Taipei 2012   83
Sunday, October 28, 12
頁籤控制器
                         UITabBarController




                           Potato Hwang @ Taiwan Taipei 2012   84
Sunday, October 28, 12
第十一堂:	
  基本元件與事件處理
                    •    事件偵測, 晃動偵測

                    •    加速度計偵測 (應用範例: 水平儀)




                                Potato Hwang @ Taiwan Taipei 2012   85
Sunday, October 28, 12
第十二堂:	
  基本元件與事件處理
                    •    Undo/Redo 機制

                    •    認識Core Motion

                    •    取得的資料




                                   Potato Hwang @ Taiwan Taipei 2012   86
Sunday, October 28, 12
Undo	
 /	
 Redo	
 機制




                              Potato Hwang @ Taiwan Taipei 2012   87
Sunday, October 28, 12
第十三堂:	
  進階篇-­‐資料存取
                    •     案路徑

                    •     案的存取

                    •    使用FMDB, 存取SQLite3資料庫




                                 Potato Hwang @ Taiwan Taipei 2012   88
Sunday, October 28, 12
Objective-C	
 :	
 Create	
 NSArray
                       //	
 方法一:	
 Creates	
 an	
 NSArray	
 with	
 one	
 object
                NSArray	
 	
 *	
 myArray	
 =	
 [NSArray	
 arrayWithObject:@"foo"];
                	
 
                //	
 Creates	
 an	
 NSArray	
 with	
 multiple	
 objects.	
 Don't	
 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                                                             89
Sunday, October 28, 12
Objective-C	
 :	
 Access	
 NSArray




                              Potato Hwang @ Taiwan Taipei 2012   90
Sunday, October 28, 12
Plist	
 檔案存取




                           Potato Hwang @ Taiwan Taipei 2012   91
Sunday, October 28, 12
Using	
  SQLite




                           Potato Hwang @ Taiwan Taipei 2012   92
Sunday, October 28, 12
Using	
  SQLite	
  –	
  with	
  FMDB




                              Potato Hwang @ Taiwan Taipei 2012   93
Sunday, October 28, 12
第十四堂:	
  進階篇-­‐表格元件
                         捲動的畫面	
  (UIScrollView)




                              Potato Hwang @ Taiwan Taipei 2012   94
Sunday, October 28, 12
第十五堂:	
  進階篇-­‐表格元件




                     !                                                              !
       UITableViewStylePlain!                                       UITableViewStyleGrouped!

                                Potato Hwang @ Taiwan Taipei 2012                              95
Sunday, October 28, 12
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   96
Sunday, October 28, 12
表格單元	
 -	
 accessoryType




                         Potato Hwang @ Taiwan Taipei 2012   97
Sunday, October 28, 12
UITableView	
 結構




                             Potato Hwang @ Taiwan Taipei 2012   98
Sunday, October 28, 12
資料來源&事件代理
                         UITableViewCell,*cell,=,[[UITableViewCell,alloc],,
                                 ,initWithStyle:,UITableViewCellStyleSubtitle,,
                                 ,reuseIdentifier:,CellIdentifier];,




                                      Potato Hwang @ Taiwan Taipei 2012           99
Sunday, October 28, 12
UITableVIew	
  結語:
                         當您在iPhone中設定一個表格,將會使用             UITableView
                                                            類別.但是
                         該類別並不知道表格名稱,包含多少區塊與欄位…etc.	
  所以必須定義一個稱
                         為UITableViewDataSource協定來解決這些問題.	
  (ex:當需要知道
                         在表格中每個區塊有多少欄位資訊時,它會依據協定呼叫已經在類別中定義
                         好的適當方法)

                UITableView類別也定義其它協定,如UITableViewDelegate.	
  此協定中
                的方法除了定義其它的資料外,還定義當表格中某一特定欄位被選取的時候,所
                要執行什麼動作.這個類別並不知道要採取什麼動作,所以由委派來負責.	
  




                                      Potato Hwang @ Taiwan Taipei 2012   100
Sunday, October 28, 12
第十六堂:	
  進階篇-­‐Core	
  Data


                    •    Entity-Relationship 模型           資料庫                    Core Data

                                                          資料表 (Table)           實體 (Entity)
                    •    使用多個表格
                                                          欄位 (Field)           屬性 (Attribute)

                    •    條件式查詢                            表格間的關聯              關係 (Relationship)

                                                                    表:資料庫與Core Data 的對應




                                       Potato Hwang @ Taiwan Taipei 2012                          101
Sunday, October 28, 12
第十七堂:	
  進階篇-­‐聯絡人資
                         料的取得與顯示
                    • 聯絡人資料的存取
                    • 資 顯示




                          Potato Hwang @ Taiwan Taipei 2012   102
Sunday, October 28, 12
聯絡人資訊
                    •    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   103
Sunday, October 28, 12
資料欄位取得(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          104
Sunday, October 28, 12
資料欄位取得(2/3)
                                                           (多筆記錄)


                                         欄位名稱                                           說明


                         KABPersonEmailProperty                      Email

                                                                     電話號碼
                         KABPersonPhoneProperty

                                                                     個人首頁
                         KABPersonURLProperty


                         KABPersonDateProperty                       個人(紀念)日期


                         KABPersonAddressProperty                    地址


                         KABPersonInstantMessageProperty             即時通      帳號




                                                    Potato Hwang @ Taiwan Taipei 2012        105
Sunday, October 28, 12
資料欄位取得(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                                                                                                106
Sunday, October 28, 12
AddressBook.framework




                               Potato Hwang @ Taiwan Taipei 2012   107
Sunday, October 28, 12
第十八堂:	
  實戰篇-­‐求籤App                           (1/2)




                    •    起始畫面的製作

                    •    供品畫面的製作

                    •    求問畫面的製作




                              Potato Hwang @ Taiwan Taipei 2012           108
Sunday, October 28, 12
第十九堂:	
  實戰篇-­‐求籤App                               (2/2)




                    •    求籤結果畫面的製作

                    •    畫面的串場

                    •    搖晃事件的處理

                    •    不透過Interface Builder產生畫面



                                  Potato Hwang @ Taiwan Taipei 2012           109
Sunday, October 28, 12
第二十堂:	
  實戰篇
                            (產品審核與上架)

                    •    編譯Ad-Hoc發     用的應用程式

                    •    專案上架

                    •    審核流程

                    •    兌換碼的使用



                                 Potato Hwang @ Taiwan Taipei 2012   110
Sunday, October 28, 12
上架Apple	
 Store	
 準備




                              Potato Hwang @ Taiwan Taipei 2012   111
Sunday, October 28, 12
iOS	
 Provisioning	
 Portal




                                 Potato Hwang @ Taiwan Taipei 2012   112
Sunday, October 28, 12
Code	
 Signing	
 設定




                             Potato Hwang @ Taiwan Taipei 2012   113
Sunday, October 28, 12
上架	
 Apple	
 Store




                             Potato Hwang @ Taiwan Taipei 2012   114
Sunday, October 28, 12
上架	
 Apple	
 Store




                    方法1: Application Loader                                  方法2: Organizer - Archives




                                              Potato Hwang @ Taiwan Taipei 2012                          115
Sunday, October 28, 12
iTune	
 Connect
                         http://itunesconnect.apple.com




                              Potato Hwang @ Taiwan Taipei 2012   116
Sunday, October 28, 12
iTunes	
 Connect
                         Manage	
 Your	
 Apps




                              Potato Hwang @ Taiwan Taipei 2012   117
Sunday, October 28, 12
Promo	
 Codes	
 兌換碼(1/3)




                                Potato Hwang @ Taiwan Taipei 2012   118
Sunday, October 28, 12
Promo	
 Codes	
 兌換碼(2/3)




                                Potato Hwang @ Taiwan Taipei 2012   119
Sunday, October 28, 12
Promo	
 Codes	
 兌換碼(3/3)




                                Potato Hwang @ Taiwan Taipei 2012   120
Sunday, October 28, 12
Thank You !



                          Potato Hwang @ Taiwan Taipei 2012   121
Sunday, October 28, 12
Misc. 雜項記錄
                         Potato Hwang @ Taipei Taiwan 2012




Sunday, October 28, 12
Lesson	
  7:	
  UIImagePicker	
  (1/2)
                                Single	
  Select




                                Potato Hwang @ Taiwan Taipei 2012   123
Sunday, October 28, 12
Lesson	
  8:	
  UIImagePicker	
  (1/2)
                                  Multi	
  Select




                                Potato Hwang @ Taiwan Taipei 2012   124
Sunday, October 28, 12
Lesson	
  9:	
  Save	
  Photo	
  to	
  
                              Camera	
  roll
                            Potato Hwang @ Taiwan Taipei 2012




                                    Potato Hwang @ Taiwan Taipei 2012   125
Sunday, October 28, 12
Lesson	
  9:	
  Save	
  Photo	
  (1/2)




                                    Potato Hwang @ Taiwan Taipei 2012   126
Sunday, October 28, 12
Lesson	
  10:	
  Take	
  Photo	
  from	
  
                                     Camera
                              Potato Hwang @ Taiwan Taipei 2012




                                      Potato Hwang @ Taiwan Taipei 2012   127
Sunday, October 28, 12
Lesson	
  10:	
  Take	
  a	
  Photo	
  from	
  Camera



                                L7#




               L9#       L10#




                                      Potato Hwang @ Taiwan Taipei 2012      128
Sunday, October 28, 12
UIKit_Framework
                                                   http://disanji.net/iOS_Doc/documentation/UIKit/Reference/UIKit_Framework/Art/
                                                                                  uikit_classes.jpg




                         Potato Hwang @ Taiwan Taipei 2012                                                                     129
Sunday, October 28, 12
Potato Hwang @ Taiwan Taipei 2012   130
Sunday, October 28, 12
Thank You !



Sunday, October 28, 12

Contenu connexe

En vedette

NCW Success Story
 NCW Success Story NCW Success Story
NCW Success StoryTom Noble
 
App cloud tool_presentation_spring_2015
App cloud tool_presentation_spring_2015App cloud tool_presentation_spring_2015
App cloud tool_presentation_spring_2015Rickey Moroney
 
SHEEHAN Narcotic Certificate
SHEEHAN Narcotic CertificateSHEEHAN Narcotic Certificate
SHEEHAN Narcotic CertificateThomas Sheehan
 
Articoli determinativi
Articoli determinativiArticoli determinativi
Articoli determinativiSpaanIt
 
3ero diagnostico (1)
3ero diagnostico (1)3ero diagnostico (1)
3ero diagnostico (1)Lupita Lanz
 
Luxury, an overview of Valentino
 Luxury, an overview of Valentino Luxury, an overview of Valentino
Luxury, an overview of ValentinoJuan Pablo Zuluaga
 
IC Engines- 2 stroke and 4 stroke
IC Engines- 2 stroke and 4 strokeIC Engines- 2 stroke and 4 stroke
IC Engines- 2 stroke and 4 strokeShivam Kumar
 

En vedette (9)

NCW Success Story
 NCW Success Story NCW Success Story
NCW Success Story
 
App cloud tool_presentation_spring_2015
App cloud tool_presentation_spring_2015App cloud tool_presentation_spring_2015
App cloud tool_presentation_spring_2015
 
DOCUMENT 2
DOCUMENT 2DOCUMENT 2
DOCUMENT 2
 
SHEEHAN Narcotic Certificate
SHEEHAN Narcotic CertificateSHEEHAN Narcotic Certificate
SHEEHAN Narcotic Certificate
 
Trucos de casa, 6
Trucos de casa, 6Trucos de casa, 6
Trucos de casa, 6
 
Articoli determinativi
Articoli determinativiArticoli determinativi
Articoli determinativi
 
3ero diagnostico (1)
3ero diagnostico (1)3ero diagnostico (1)
3ero diagnostico (1)
 
Luxury, an overview of Valentino
 Luxury, an overview of Valentino Luxury, an overview of Valentino
Luxury, an overview of Valentino
 
IC Engines- 2 stroke and 4 stroke
IC Engines- 2 stroke and 4 strokeIC Engines- 2 stroke and 4 stroke
IC Engines- 2 stroke and 4 stroke
 

Plus de 芋頭 烤

空英課程 Agile development 2014
空英課程 Agile development 2014空英課程 Agile development 2014
空英課程 Agile development 2014芋頭 烤
 
上帝SOP, ORTV-早禱會分享-George Huang
上帝SOP, ORTV-早禱會分享-George Huang上帝SOP, ORTV-早禱會分享-George Huang
上帝SOP, ORTV-早禱會分享-George Huang芋頭 烤
 
消防員筆記(Fire proof) 搶救:挑戰 愛情40天
消防員筆記(Fire proof)  搶救:挑戰 愛情40天消防員筆記(Fire proof)  搶救:挑戰 愛情40天
消防員筆記(Fire proof) 搶救:挑戰 愛情40天芋頭 烤
 
分享 06-03~06-04信心的旅程 (ortv培靈週day1+2), spiritual emphasis week
分享 06-03~06-04信心的旅程 (ortv培靈週day1+2), spiritual emphasis week分享 06-03~06-04信心的旅程 (ortv培靈週day1+2), spiritual emphasis week
分享 06-03~06-04信心的旅程 (ortv培靈週day1+2), spiritual emphasis week芋頭 烤
 
07-15,2014 榮美週二小組, (主題分享,上帝之子影集2:摩西 & 出埃及)
07-15,2014 榮美週二小組, (主題分享,上帝之子影集2:摩西 & 出埃及)07-15,2014 榮美週二小組, (主題分享,上帝之子影集2:摩西 & 出埃及)
07-15,2014 榮美週二小組, (主題分享,上帝之子影集2:摩西 & 出埃及)芋頭 烤
 
7/8,2014 榮美週二小組, (主題分享,上帝之子影集1:挪亞方舟、亞伯拉罕)
7/8,2014 榮美週二小組, (主題分享,上帝之子影集1:挪亞方舟、亞伯拉罕)7/8,2014 榮美週二小組, (主題分享,上帝之子影集1:挪亞方舟、亞伯拉罕)
7/8,2014 榮美週二小組, (主題分享,上帝之子影集1:挪亞方舟、亞伯拉罕)芋頭 烤
 
空英-iCloud & Evernote 快速筆記
空英-iCloud & Evernote 快速筆記空英-iCloud & Evernote 快速筆記
空英-iCloud & Evernote 快速筆記芋頭 烤
 
Information security
Information securityInformation security
Information security芋頭 烤
 
Personal data protection
Personal data protectionPersonal data protection
Personal data protection芋頭 烤
 

Plus de 芋頭 烤 (9)

空英課程 Agile development 2014
空英課程 Agile development 2014空英課程 Agile development 2014
空英課程 Agile development 2014
 
上帝SOP, ORTV-早禱會分享-George Huang
上帝SOP, ORTV-早禱會分享-George Huang上帝SOP, ORTV-早禱會分享-George Huang
上帝SOP, ORTV-早禱會分享-George Huang
 
消防員筆記(Fire proof) 搶救:挑戰 愛情40天
消防員筆記(Fire proof)  搶救:挑戰 愛情40天消防員筆記(Fire proof)  搶救:挑戰 愛情40天
消防員筆記(Fire proof) 搶救:挑戰 愛情40天
 
分享 06-03~06-04信心的旅程 (ortv培靈週day1+2), spiritual emphasis week
分享 06-03~06-04信心的旅程 (ortv培靈週day1+2), spiritual emphasis week分享 06-03~06-04信心的旅程 (ortv培靈週day1+2), spiritual emphasis week
分享 06-03~06-04信心的旅程 (ortv培靈週day1+2), spiritual emphasis week
 
07-15,2014 榮美週二小組, (主題分享,上帝之子影集2:摩西 & 出埃及)
07-15,2014 榮美週二小組, (主題分享,上帝之子影集2:摩西 & 出埃及)07-15,2014 榮美週二小組, (主題分享,上帝之子影集2:摩西 & 出埃及)
07-15,2014 榮美週二小組, (主題分享,上帝之子影集2:摩西 & 出埃及)
 
7/8,2014 榮美週二小組, (主題分享,上帝之子影集1:挪亞方舟、亞伯拉罕)
7/8,2014 榮美週二小組, (主題分享,上帝之子影集1:挪亞方舟、亞伯拉罕)7/8,2014 榮美週二小組, (主題分享,上帝之子影集1:挪亞方舟、亞伯拉罕)
7/8,2014 榮美週二小組, (主題分享,上帝之子影集1:挪亞方舟、亞伯拉罕)
 
空英-iCloud & Evernote 快速筆記
空英-iCloud & Evernote 快速筆記空英-iCloud & Evernote 快速筆記
空英-iCloud & Evernote 快速筆記
 
Information security
Information securityInformation security
Information security
 
Personal data protection
Personal data protectionPersonal data protection
Personal data protection
 

Dernier

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 

Dernier (20)

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 

Potato Hwang Object-C Mobile DEV sharing 130 Slides

  • 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 1 Sunday, October 28, 12
  • 2. INTRODUCE MYSELF 中文姓名: 黃于爵 英文姓名: Potato Hwang 學歷: 國立雲林科技大學 資 管理所 (碩)(畢) 2 Potato Hwang @ Taiwan Taipei 2012 Sunday, October 28, 12
  • 3. Potato’作品集 Potato Hwang @ Taiwan Taipei 2012 3 Sunday, October 28, 12
  • 4. Apple iOS 介紹 • iOS市場慨況介紹 • 開發平台與開發方式介紹  (Mac+iPhone/iPad/模擬器) • 開發者帳號的申請與認識 • 證書的申請與iOS  Provisioning  Portal  使用 • 熟悉MacOS及Xcode安裝 • 透過Xcode撰寫第一個程式 Potato Hwang @ Taiwan Taipei 2012 4 Sunday, October 28, 12
  • 5. iOS 6 Potato Hwang @ Taiwan Taipei 2012 5 Sunday, October 28, 12
  • 6. Potato Hwang @ Taiwan Taipei 2012 6 Sunday, October 28, 12
  • 7. Potato Hwang @ Taiwan Taipei 2012 7 Sunday, October 28, 12
  • 8. Potato Hwang @ Taiwan Taipei 2012 8 Sunday, October 28, 12
  • 9. Potato Hwang @ Taiwan Taipei 2012 9 Sunday, October 28, 12
  • 10. Potato Hwang @ Taiwan Taipei 2012 10 Sunday, October 28, 12
  • 11. Potato Hwang @ Taiwan Taipei 2012 11 Sunday, October 28, 12
  • 12. Potato Hwang @ Taiwan Taipei 2012 12 Sunday, October 28, 12
  • 13. Potato Hwang @ Taiwan Taipei 2012 13 Sunday, October 28, 12
  • 14. Potato Hwang @ Taiwan Taipei 2012 14 Sunday, October 28, 12
  • 15. Potato Hwang @ Taiwan Taipei 2012 15 Sunday, October 28, 12
  • 16. OSX Mountain Lion Potato Hwang @ Taiwan Taipei 2012 16 Sunday, October 28, 12
  • 17. iPhone/iPad程式開發流程 XCode& ( )& ( )& Potato Hwang @ Taiwan Taipei 2012 17 Sunday, October 28, 12
  • 18. iOS Developer Programs 個人/公司 皆可申請 必須公司才能申請 (可上架 App Store) (不可上架 App Store) Potato Hwang @ Taiwan Taipei 2012 18 Sunday, October 28, 12
  • 19. 三種發佈模式 • Ad Hoc (內) - 可安裝100部以內的設備透過iTunes即可, 不須經過App Store. • In-House (內) - 內部應用程式使用,可輕鬆安裝程式至大量機器上,且不須經過App Store • App Store (外)- 實際上架App Store - 正式申請Apple審核, 審核過關後即可上架至Apple Store 供人自由下載. Potato Hwang @ Taiwan Taipei 2012 19 Sunday, October 28, 12
  • 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 20 Sunday, October 28, 12
  • 21. 證書(Certificate)申請(2/5) Step4: ' Step3:' ' Potato Hwang @ Taiwan Taipei 2012 21 Sunday, October 28, 12
  • 22. 證書(Certificate)申請(3/5) https://developer.apple.com/devcenter/ios/3 Potato Hwang @ Taiwan Taipei 2012 22 Sunday, October 28, 12
  • 23. 證書(Certificate)申請(4/5) https://developer.apple.com/ios/manage/overview/5 Potato Hwang @ Taiwan Taipei 2012 23 Sunday, October 28, 12
  • 24. 證書(Certificate)申請(5/5) Potato Hwang @ Taiwan Taipei 2012 24 Sunday, October 28, 12
  • 25. 新增設備 Potato Hwang @ Taiwan Taipei 2012 25 Sunday, October 28, 12
  • 26. 新增App ID ! ! Potato Hwang @ Taiwan Taipei 2012 26 Sunday, October 28, 12
  • 27. 描述檔 (Provisioning Profile)(1/2) App#ID# Local# #for#Dev# Potato Hwang @ Taiwan Taipei 2012 27 Sunday, October 28, 12
  • 28. 描述檔 (Provisioning Profile)(2/2) Local& &for&Distribution& & Potato Hwang @ Taiwan Taipei 2012 28 Sunday, October 28, 12
  • 29. 熟悉Mac  常用快捷鍵  (1/2) Potato Hwang @ Taiwan Taipei 2012 29 Sunday, October 28, 12
  • 30. 熟悉Mac  常用快捷鍵  (2/2) Potato Hwang @ Taiwan Taipei 2012 30 Sunday, October 28, 12
  • 31. XCode常用快捷鍵 快速搜尋: 將Project中具有相似名稱內容全部列出來! Potato Hwang @ Taiwan Taipei 2012 31 Sunday, October 28, 12
  • 32. 第二堂:  入門篇-­‐開發工具 • 認識Xcode • Hello World 1.0 使用XIB • Hello World 2.0 使用Storyboard • 修改圖示以及顯示名稱 • 在實體手機上執行 • iOS模擬器的使用 • Organizer的使用 Potato Hwang @ Taiwan Taipei 2012 32 Sunday, October 28, 12
  • 33. Hello  World  1.0  使用XIB Potato Hwang @ Taiwan Taipei 2012 33 Sunday, October 28, 12
  • 34. Hello  World  2.0  使用Storyboard Potato Hwang @ Taiwan Taipei 2012 34 Sunday, October 28, 12
  • 35. 第三堂:  Object  C  語言基礎 • iOS作業系統架構介紹 • 從C到 Object C • 選擇器與 息 • 輸出到主控台 • 類別 (Class) • #import 與@class • 變數的存取權限 • 建構子與解構子 Potato Hwang @ Taiwan Taipei 2012 35 Sunday, October 28, 12
  • 36. 類別(Class)-­‐暗黑3的五個角色(1/3) Potato Hwang @ Taiwan Taipei 2012 36 Sunday, October 28, 12
  • 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 37 Sunday, October 28, 12
  • 38. 訊息傳遞  (Message)  (3/3) ! ! Potato Hwang @ Taiwan Taipei 2012 38 Sunday, October 28, 12
  • 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 39 Sunday, October 28, 12
  • 40. 變數的存取權限 // Main() , data + @interfacc*Configuration:*NSObject* + + {* @public* , ******@public* .* (Default), ************NSDictionary**data;* @protected* .* ******@private* , @private* ************NSDictionary**filename;* .* }* @end* Potato Hwang @ Taiwan Taipei 2012 40 Sunday, October 28, 12
  • 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 41 Sunday, October 28, 12
  • 42. Object  C  常用檔案類型 Potato Hwang @ Taiwan Taipei 2012 42 Sunday, October 28, 12
  • 43. 選擇器與訊息  (1/2) !""(void)""setName"":""(NSString"*)""input" " " " " " " " // setName " [self"setName":"input];" " " " " Potato Hwang @ Taiwan Taipei 2012 43 Sunday, October 28, 12
  • 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 44 Sunday, October 28, 12
  • 45. 物件的概念  (object-­‐oriented)1/3 ! ! ! Potato Hwang @ Taiwan Taipei 2012 45 Sunday, October 28, 12
  • 46. 物件的概念  (object-­‐oriented)2/3 ! ! ! ! ! ! 80°C! 80°C! ! ! ! ! 1)  ! ! 2)  ! 3)  ! ! ! LED ! ! ! ! Potato Hwang @ Taiwan Taipei 2012 46 Sunday, October 28, 12
  • 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 47 Sunday, October 28, 12
  • 48. 介面的概念  (Interface) ! ! ! ! ! ! ! ! Potato Hwang @ Taiwan Taipei 2012 48 Sunday, October 28, 12
  • 49. iOS作業系統架構介紹 , " , " Potato Hwang @ Taiwan Taipei 2012 49 Sunday, October 28, 12
  • 50. 第四堂:  Object  C  語言基礎 • 點運算子 • 協定Protocol • 分類Category • Block物件 • 例外補抓 • 例外拋出 • 資料類型 • 記憶體管理 Potato Hwang @ Taiwan Taipei 2012 50 Sunday, October 28, 12
  • 51. @property  ,  @synthesize 定義成員變數存取方式 Potato Hwang @ Taiwan Taipei 2012 51 Sunday, October 28, 12
  • 52. @property  ,  @synthesize Potato Hwang @ Taiwan Taipei 2012 52 Sunday, October 28, 12
  • 53. @property  ,  @synthesize Potato Hwang @ Taiwan Taipei 2012 53 Sunday, October 28, 12
  • 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 54 Sunday, October 28, 12
  • 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 55 Sunday, October 28, 12
  • 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 56 Sunday, October 28, 12
  • 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 57 Sunday, October 28, 12
  • 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 58 Sunday, October 28, 12
  • 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 59 Sunday, October 28, 12
  • 60. 記憶體管理 (1/3) +1% +1% .1% .1% alloc%% retain% release% release% Potato Hwang @ Taiwan Taipei 2012 60 Sunday, October 28, 12
  • 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 61 Sunday, October 28, 12
  • 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 62 Sunday, October 28, 12
  • 63. 記憶體管理 Q&A (3/3) Q1: What is the difference between copy and retain ? Potato Hwang @ Taiwan Taipei 2012 63 Sunday, October 28, 12
  • 64. 第五堂:  入門篇-­‐基本機制 • 四大重要類別 - UIDevice, UIApplication, UIScreen, UIWindow • 三大重要機制 - 代理機制與事件處理 - 息通知機制 - Target Action 機制 Potato Hwang @ Taiwan Taipei 2012 64 Sunday, October 28, 12
  • 65. 四大重要類別 • 設備本身 UIDevice • 應用程式本身 UIApplication • 手機螢幕 UIScreen • 主視窗 UIWindow Potato Hwang @ Taiwan Taipei 2012 65 Sunday, October 28, 12
  • 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 66 Sunday, October 28, 12
  • 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 67 Sunday, October 28, 12
  • 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 68 Sunday, October 28, 12
  • 69. 第六堂:  基本元件與事件處理 • 一切畫面元件的開始 UIView • 座標系統 • 子畫面的加入與移除 • 多點觸 事件的處理 • 具有圓角的UIView • 動畫效果 Potato Hwang @ Taiwan Taipei 2012 69 Sunday, October 28, 12
  • 70. Practice-保存期限 Potato Hwang @ Taiwan Taipei 2012 70 Sunday, October 28, 12
  • 71. View Controller Methods Potato Hwang @ Taiwan Taipei 2012 71 Sunday, October 28, 12
  • 72. 第七堂:  基本元件與事件處理 • GUI元件的使用 -對話盒的使用 - 動作清單元件 - 日期選擇元件 - 滾輪元件 - 活動狀態指示元件 - 進度狀態指示元件 - 標記的使用 Potato Hwang @ Taiwan Taipei 2012 72 Sunday, October 28, 12
  • 73. 對話盒元件 UIAlertView Potato Hwang @ Taiwan Taipei 2012 73 Sunday, October 28, 12
  • 74. 動作清單元件 UIActionSheet Potato Hwang @ Taiwan Taipei 2012 74 Sunday, October 28, 12
  • 75. 進度狀態指示元件 UIProgressView Potato Hwang @ Taiwan Taipei 2012 75 Sunday, October 28, 12
  • 76. 第八堂:  基本元件與事件處理 • GUI元件的使用 - 文字顯示元件 - 單行文字輸入元件 - 多行文字輸入元件 Potato Hwang @ Taiwan Taipei 2012 76 Sunday, October 28, 12
  • 77. 第九堂:  基本元件與事件處理 • GUI元件的使用 - 手勢辨識 - UIAppearance的使用 Potato Hwang @ Taiwan Taipei 2012 77 Sunday, October 28, 12
  • 78. 手勢辨識 • UITabGestureRecognizer: 輕拍 • UIPinchGestureRecognizer: 捏放 • UIRotationGestureRecognizer: 旋轉 • UISwipeGestureRecognizer: 掃過 • UIPanGestureRecognizer: 平移 • UILongPressGestureRecognizer: 長按 Potato Hwang @ Taiwan Taipei 2012 78 Sunday, October 28, 12
  • 79. UIAppearance的使用 一次改變某個元件的外觀. (ex:導航列) • Category • +appearance - 一次性的改變所有使用到某元件的外觀. • +appearanceWhenContainedIn - 條件性的設定,改變某元件外觀. Potato Hwang @ Taiwan Taipei 2012 79 Sunday, October 28, 12
  • 80. 第十堂:  基本元件與事件處理 • 畫面的管理 • 導覽列控制器 • 頁籤的使用 Potato Hwang @ Taiwan Taipei 2012 80 Sunday, October 28, 12
  • 81. 畫面的管理 (1/2) UIView賦予iOS畫面, UIViewController則帶給了 UIView生命! Potato Hwang @ Taiwan Taipei 2012 81 Sunday, October 28, 12
  • 82. 畫面的管理 (2/2) • 所有畫面都是以ViewController為單位. - 每一個畫面背後都有一個ViewController來控 制著畫面. Potato Hwang @ Taiwan Taipei 2012 82 Sunday, October 28, 12
  • 83. 導覽列控制器 UINavigationController Potato Hwang @ Taiwan Taipei 2012 83 Sunday, October 28, 12
  • 84. 頁籤控制器 UITabBarController Potato Hwang @ Taiwan Taipei 2012 84 Sunday, October 28, 12
  • 85. 第十一堂:  基本元件與事件處理 • 事件偵測, 晃動偵測 • 加速度計偵測 (應用範例: 水平儀) Potato Hwang @ Taiwan Taipei 2012 85 Sunday, October 28, 12
  • 86. 第十二堂:  基本元件與事件處理 • Undo/Redo 機制 • 認識Core Motion • 取得的資料 Potato Hwang @ Taiwan Taipei 2012 86 Sunday, October 28, 12
  • 87. Undo / Redo 機制 Potato Hwang @ Taiwan Taipei 2012 87 Sunday, October 28, 12
  • 88. 第十三堂:  進階篇-­‐資料存取 • 案路徑 • 案的存取 • 使用FMDB, 存取SQLite3資料庫 Potato Hwang @ Taiwan Taipei 2012 88 Sunday, October 28, 12
  • 89. Objective-C : Create NSArray // 方法一: Creates an NSArray with one object NSArray * myArray = [NSArray arrayWithObject:@"foo"]; // Creates an NSArray with multiple objects. Don't 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 89 Sunday, October 28, 12
  • 90. Objective-C : Access NSArray Potato Hwang @ Taiwan Taipei 2012 90 Sunday, October 28, 12
  • 91. Plist 檔案存取 Potato Hwang @ Taiwan Taipei 2012 91 Sunday, October 28, 12
  • 92. Using  SQLite Potato Hwang @ Taiwan Taipei 2012 92 Sunday, October 28, 12
  • 93. Using  SQLite  –  with  FMDB Potato Hwang @ Taiwan Taipei 2012 93 Sunday, October 28, 12
  • 94. 第十四堂:  進階篇-­‐表格元件 捲動的畫面  (UIScrollView) Potato Hwang @ Taiwan Taipei 2012 94 Sunday, October 28, 12
  • 95. 第十五堂:  進階篇-­‐表格元件 ! ! UITableViewStylePlain! UITableViewStyleGrouped! Potato Hwang @ Taiwan Taipei 2012 95 Sunday, October 28, 12
  • 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 96 Sunday, October 28, 12
  • 97. 表格單元 - accessoryType Potato Hwang @ Taiwan Taipei 2012 97 Sunday, October 28, 12
  • 98. UITableView 結構 Potato Hwang @ Taiwan Taipei 2012 98 Sunday, October 28, 12
  • 99. 資料來源&事件代理 UITableViewCell,*cell,=,[[UITableViewCell,alloc],, ,initWithStyle:,UITableViewCellStyleSubtitle,, ,reuseIdentifier:,CellIdentifier];, Potato Hwang @ Taiwan Taipei 2012 99 Sunday, October 28, 12
  • 100. UITableVIew  結語: 當您在iPhone中設定一個表格,將會使用 UITableView 類別.但是 該類別並不知道表格名稱,包含多少區塊與欄位…etc.  所以必須定義一個稱 為UITableViewDataSource協定來解決這些問題.  (ex:當需要知道 在表格中每個區塊有多少欄位資訊時,它會依據協定呼叫已經在類別中定義 好的適當方法) UITableView類別也定義其它協定,如UITableViewDelegate.  此協定中 的方法除了定義其它的資料外,還定義當表格中某一特定欄位被選取的時候,所 要執行什麼動作.這個類別並不知道要採取什麼動作,所以由委派來負責.   Potato Hwang @ Taiwan Taipei 2012 100 Sunday, October 28, 12
  • 101. 第十六堂:  進階篇-­‐Core  Data • Entity-Relationship 模型 資料庫 Core Data 資料表 (Table) 實體 (Entity) • 使用多個表格 欄位 (Field) 屬性 (Attribute) • 條件式查詢 表格間的關聯 關係 (Relationship) 表:資料庫與Core Data 的對應 Potato Hwang @ Taiwan Taipei 2012 101 Sunday, October 28, 12
  • 102. 第十七堂:  進階篇-­‐聯絡人資 料的取得與顯示 • 聯絡人資料的存取 • 資 顯示 Potato Hwang @ Taiwan Taipei 2012 102 Sunday, October 28, 12
  • 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 103 Sunday, October 28, 12
  • 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 104 Sunday, October 28, 12
  • 105. 資料欄位取得(2/3) (多筆記錄) 欄位名稱 說明 KABPersonEmailProperty Email 電話號碼 KABPersonPhoneProperty 個人首頁 KABPersonURLProperty KABPersonDateProperty 個人(紀念)日期 KABPersonAddressProperty 地址 KABPersonInstantMessageProperty 即時通 帳號 Potato Hwang @ Taiwan Taipei 2012 105 Sunday, October 28, 12
  • 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 106 Sunday, October 28, 12
  • 107. AddressBook.framework Potato Hwang @ Taiwan Taipei 2012 107 Sunday, October 28, 12
  • 108. 第十八堂:  實戰篇-­‐求籤App (1/2) • 起始畫面的製作 • 供品畫面的製作 • 求問畫面的製作 Potato Hwang @ Taiwan Taipei 2012 108 Sunday, October 28, 12
  • 109. 第十九堂:  實戰篇-­‐求籤App (2/2) • 求籤結果畫面的製作 • 畫面的串場 • 搖晃事件的處理 • 不透過Interface Builder產生畫面 Potato Hwang @ Taiwan Taipei 2012 109 Sunday, October 28, 12
  • 110. 第二十堂:  實戰篇 (產品審核與上架) • 編譯Ad-Hoc發 用的應用程式 • 專案上架 • 審核流程 • 兌換碼的使用 Potato Hwang @ Taiwan Taipei 2012 110 Sunday, October 28, 12
  • 111. 上架Apple Store 準備 Potato Hwang @ Taiwan Taipei 2012 111 Sunday, October 28, 12
  • 112. iOS Provisioning Portal Potato Hwang @ Taiwan Taipei 2012 112 Sunday, October 28, 12
  • 113. Code Signing 設定 Potato Hwang @ Taiwan Taipei 2012 113 Sunday, October 28, 12
  • 114. 上架 Apple Store Potato Hwang @ Taiwan Taipei 2012 114 Sunday, October 28, 12
  • 115. 上架 Apple Store 方法1: Application Loader 方法2: Organizer - Archives Potato Hwang @ Taiwan Taipei 2012 115 Sunday, October 28, 12
  • 116. iTune Connect http://itunesconnect.apple.com Potato Hwang @ Taiwan Taipei 2012 116 Sunday, October 28, 12
  • 117. iTunes Connect Manage Your Apps Potato Hwang @ Taiwan Taipei 2012 117 Sunday, October 28, 12
  • 118. Promo Codes 兌換碼(1/3) Potato Hwang @ Taiwan Taipei 2012 118 Sunday, October 28, 12
  • 119. Promo Codes 兌換碼(2/3) Potato Hwang @ Taiwan Taipei 2012 119 Sunday, October 28, 12
  • 120. Promo Codes 兌換碼(3/3) Potato Hwang @ Taiwan Taipei 2012 120 Sunday, October 28, 12
  • 121. Thank You ! Potato Hwang @ Taiwan Taipei 2012 121 Sunday, October 28, 12
  • 122. Misc. 雜項記錄 Potato Hwang @ Taipei Taiwan 2012 Sunday, October 28, 12
  • 123. Lesson  7:  UIImagePicker  (1/2) Single  Select Potato Hwang @ Taiwan Taipei 2012 123 Sunday, October 28, 12
  • 124. Lesson  8:  UIImagePicker  (1/2) Multi  Select Potato Hwang @ Taiwan Taipei 2012 124 Sunday, October 28, 12
  • 125. Lesson  9:  Save  Photo  to   Camera  roll Potato Hwang @ Taiwan Taipei 2012 Potato Hwang @ Taiwan Taipei 2012 125 Sunday, October 28, 12
  • 126. Lesson  9:  Save  Photo  (1/2) Potato Hwang @ Taiwan Taipei 2012 126 Sunday, October 28, 12
  • 127. Lesson  10:  Take  Photo  from   Camera Potato Hwang @ Taiwan Taipei 2012 Potato Hwang @ Taiwan Taipei 2012 127 Sunday, October 28, 12
  • 128. Lesson  10:  Take  a  Photo  from  Camera L7# L9# L10# Potato Hwang @ Taiwan Taipei 2012 128 Sunday, October 28, 12
  • 129. UIKit_Framework http://disanji.net/iOS_Doc/documentation/UIKit/Reference/UIKit_Framework/Art/ uikit_classes.jpg Potato Hwang @ Taiwan Taipei 2012 129 Sunday, October 28, 12
  • 130. Potato Hwang @ Taiwan Taipei 2012 130 Sunday, October 28, 12
  • 131. Thank You ! Sunday, October 28, 12