SlideShare a Scribd company logo
BECOME AN XCODER




                   1
BECOME AN XCODER


Copyright © 2006 by Bert Altenburg, Alex Clarke and Philippe Mougin. Version 1.2.

Attribution: The licensors, Bert Altenburg, Alex Clarke and Philippe Mougin, permit others to copy,
modify and distribute the work. In return, the licensees must give the original authors credit.

Non-commercial: The licensors permit others to copy, modify and distribute the work and use the
work in paid-for and free courses. In return, licensees may not sell the work itself, although it may
accompany other work that is sold.




                                                                                                   2
BECOME AN XCODER




            __________________________________________________ 4

    0                         ______________________________________ 5

    1                                  _____________________________ 7

    2                                       __________________________ 13

    3          ______________________________________________ 14

    4                       _______________________________________ 20

    5                         _____________________________________ 25

    6                 __________________________________________ 33

    7              while            _______________________________ 36

    8                                 GUI         ___________________ 39

    9                       _______________________________________ 55

    10     awakeFromNib_____________________________________ 59

    11         ______________________________________________ 61

    12         ______________________________________________ 63

    13         ______________________________________________ 69

    14                     _________________________________________ 73

    15                __________________________________________ 75




                                                                        3
BECOME AN XCODER




Apple                                 Cocoa
        Xcode                  Mac OS X              Apple


                   Mac
                      Objective-C      Xcode
                                       (GUI)




                                               [4]


[4.3]       [4]


volume = baseArea * height;         // [4.3]




                                                         Xcode




                                                                 4
BECOME AN XCODER                                                           0




                                             0

                                                             Mac                  Macintosh




1.                       Mac                            Mac                       Mac
        Mac                                          Objective-C   AppleScript
                                               AppleScript
                   AppleScript for Absolute Starters

                            http://www.macscripter.net/books

2.           Macintosh                                               PC
     Mac T                                                  Mac
                      Mac                                                               Mac


                                       distributed computing, DC
                      Folding@home       SETI@home
                              DC                                                   DC
                                             Mac                                        DC
                                                                                 Mac
              DC                                                                        Mac
                                                                           Mac
                                                Mac                                     DC
                                                          DC

                   http://distributedcomputing.info/projects.html



3.      Macintosh




4.                             Macintosh




                                                                                          5
BECOME AN XCODER                    0


5.                      Macintosh


                   DC




                                        6
BECOME AN XCODER                                            1




                                            1


                                       Xcode


                                 Objective-C



2+6=

  =3*4        *

                                                x       y


2+6=x

y=3*4

Objective-C
                  Objective-C          statement


[1]
x = 4;

      x       4
                                 ...      [1]
                                                                compiler
                                Mac                 0   1




                                                                  Mac




                                                                           7
BECOME AN XCODER                                                   1


                                                    bug
      debugging

                                                x
                             pictureWidth [2]

[2]
pictureWidth = 8;




          pictureWidth    pictureWIDTH              PictureWidth


                  [2]




  Objective-C                       Objective-C
                         pictureWidth




                                                                       "_"




                   door8k do8or        do_or
                     door 8                               8door
                     Door8


                                                    [3]

[3]
pictureWidth=8;
pictureHeight=6;
pictureSurfaceArea=pictureWidth*pictureHeight;




                                                                             8
BECOME AN XCODER                                                         1


[4]
pictureWidth = 8;
pictureHeight = 6;
pictureSurfaceArea = pictureWidth * pictureHeight;

                    [5]

[5]
pictureWidth = 8;
pictureHeight = 4.5;
pictureSurfaceArea = pictureWidth * pictureHeight;

                                                   integers                          [5.1]     [5.2]


                                                                                       floating-
point

        [5]


"               "

[6]
int pictureWidth;
float pictureHeight, pictureSurfaceArea;
pictureWidth = 8;
pictureHeight = 4.5;
pictureSurfaceArea = pictureWidth * pictureHeight;

    [6.1]       int                     pictureWidth           integer
                                                                         [6.2]
      float
pictureWidth                                                                            int
        float                                                                         pictureSur-
faceArea                  [6.2]




                                  int      float




                                                              int    float
                                                                         long long    double

                                                                                                  9
BECOME AN XCODER                                                     1




    [7]
    unsigned int chocolateBarsInStock;

                                    unsigned int                unsigned int


                                            [8]

[8]
int x = 10;
float y= 3.5, z = 42;




      operators

+

-

/

*

                                                                               Objective-C


                    x = x + 1;                     [9]   [10]

[9]
x++;


[10]
++x;

                         x                         ++
                  [11]       [12]

[11]
x = 10;


                                                                                             10
BECOME AN XCODER                                                         1


y = 2 * (x++);


[12]
x = 10;
y = 2 * (++x);

           [11]                               y         20      x        11                     [12.2]
      x             2                 1                 x       11   y         22        [12]
                  [13]

[13]
x = 10;
x++;
y = 2 * x;




                                      *   /   +       -                      2*3+4        10
                                                      2 * (3 + 4)    14


[14, 15]

[14]
int x = 5, y = 12, ratio;
ratio =       y / x;


[15]
float x = 5, y = 12, ratio;
ratio =       y / x;

           [14]                   2                   [15]
2.4

  %                                               %                                 operand
                                                                     %

  [16]
  int x = 13, y = 5, remainder;
  remainder =            x % y;




                                                                                                   11
BECOME AN XCODER                              1


           remainder      3     x   2*y + 3




  21 % 7     0         30 % 2   0             50 % 9    5

  22 % 7     1         31 % 2   1             60 % 29       2

  23 % 7     2         32 % 2   0

  24 % 7     3         33 % 2   1

  27 % 7     6         34 % 2   0




                                                                12
BECOME AN XCODER                                     2




                                     2

                                                                      [1]

[1]
float pictureWidth, pictureHeight, pictureSurfaceArea;
pictureWidth = 8.0;
pictureHeight = 4.5;
pictureSurfaceArea = pictureWidth * pictureHeight;




//

     Xcode                                                       /*   */

/*
              */

      Xcode
                       outcomment                        /* */




                                                                            13
BECOME AN XCODER                                                         3




                                                3


                      Objective-C




                                            function


                             main()                    main()


                            main()    [1]

[1]
main()
{
    // main()
}

         [1.1]                        "main"                    "main"
             main()


                [1.2,1.5]

                            [2]

[2]
main()
{
    //
    float pictureWidth, pictureHeight, pictureSurfaceArea;


    //


                                                                             14
BECOME AN XCODER                                                       3


    pictureWidth = 8.0;
    pictureHeight = 4.5;


    //
    pictureSurfaceArea = pictureWidth * pictureHeight;
}

                                   main()
                                                                           main()
                                     circleArea()   [3]

[3]
main()
{
    float pictureWidth, pictureHeight, pictureSurfaceArea;
    pictureWidth = 8.0;
    pictureHeight = 4.5;
    pictureSurfaceArea = pictureWidth * pictureHeight;
}


circleArea()          // [3.9]
{


}

                                 [3.9]
         main()

                  circleArea()           main()                  [4]

[4]
main()
{
    float pictureWidth, pictureHeight, pictureSurfaceArea,
           circleRadius, circleSurfaceArea;          // [4.4]
    pictureWidth       = 8.0;
    pictureHeight = 4.5;
    circleRadius       = 5.0; // [4.7]
    pictureSurfaceArea =         pictureWidth * pictureHeight;




                                                                              15
BECOME AN XCODER                                                                                    3


    //
    circleSurfaceArea = circleArea(circleRadius); // [4.11]
}

                                                                   [3]

                             float        [4.4]                  initialize         circleRadius
         [4.7]                                [4.11]               circleArea()
                    circleRadius                                         circleArea()                argument
                 circleRadius                            circleArea()            circleArea()
                                              return                               [3]        circleArea()
                     [5]

                               circleArea()

[5]
circleArea(float theRadius) // [5.1]
{
    float theArea;
    //               pi               r
    theArea = 3.1416 * theRadius * theRadius; //[5.5]
    return theArea;
}

    [5.1]                      circleArea()
                           theRadius                                                theArea             [5.5]
                                              [5.3]             main        [4.4]
                          theRadius                  [5.1]                             [5.6]
                                                   [4.11]          circleSurfaceArea

            [5]

         float        [6.1]

[6]
float circleArea(float theRadius)
{
    float theArea;
    theArea = 3.1416 * theRadius * theRadius;
    return theArea;
}



                                                                                                          16
BECOME AN XCODER                                                                        3


           [6.1]                                                             theArea
   float                                                     main()             circleSurfaceArea
[4.11]




   [7]
   int throwDice()
   {
              int noOfEyes;


              //               1   6


              return noOfEyes;
   }

                                                                              “void”
   “return”                                                 return


   [8]
   void beepXTimes(int x);
   {
              //        x
              return;
   }

                                                      pictureSurfaceArea()


   [9]
   float pictureSurfaceArea(float theWidth, float theHeight)
   {
              //
   }

main()                                                                       return
             0     [10.10]                                                   main()
                      main()           "int" [10.1]

[10]



                                                                                              17
BECOME AN XCODER                                                                           3


int main()
{
    float pictureWidth, pictureHeight, pictureSurfaceArea,
          circleRadius, circleSurfaceArea;
    pictureWidth = 8;
    pictureHeight = 4.5;
    circleRadius = 5.0;
    pictureSurfaceArea =          pictureWidth * pictureHeight;
    circleSurfaceArea = circleArea(circleRadius);
    return 0;      // [10.10]
}


float circleArea(float theRadius)                              // [10.13]
{
    float theArea;
    theArea = 3.1416 * theRadius * theRadius;
    return theArea;
}

                  [10]                      [10.1]          main()          [10.13]
                                                                               [10.9]
                                  circleArea()                                          main()


  warning                                            int main()                            function
declaration              [11.1]                              [10.13]


[11]
float circleArea(float theRadius);               //


int main()
{

                                                        [10]




rectangleArea()                           [12]                                     main()




                                                                                                 18
BECOME AN XCODER                                                                3


main()




[12]
float rectangleArea(float length, float width)
{
    return (length * width);
}

                                                       [12.3]
                 [10.15]                     theArea




          [12]

         rectangleArea

                               float

                                            float                      [12.1]


                                                                Objective-C
                                                                                    Xcode
                     [11]




                                                                                      19
BECOME AN XCODER                                                           4




                                                 4


                                                                                     Cocoa
                 NSLog()
"       "

    NSLog()
                                                                                Cocoa


                NSLog()

[1]
int main()
{
    NSLog(@"Julia is a pretty actress.");
    return 0;
}

                 [1]                   "Julia is a pretty actress."        @"    "
                   string

                     NSLog()
                               [1]

2005-12-22 17:39:23.084 test[399] Julia is a pretty actress.

                                     character

                                     main()

[2]
NSLog(@"");
NSLog(@" ");

        [2.1]                                          empty string
[2.2]                                                              space
   1




                                                                                        20
BECOME AN XCODER                                                  4




                                                      [3.1]               n


[3]
NSLog(@"Julia is a pretty nactress.");



Julia is a pretty
actress.

   [3.1]                       escape               NSLog()
                                                        "n"   "       "




                                                    NSLog()



  [4]
  NSLog(@"Julia is a pretty actress.n");

           [4.1]

  Julia is a pretty actress.n



[5]
int x, integerToDisplay;
x = 1;
integerToDisplay = 5 + x;
NSLog(@"The value of the integer is %d.", integerToDisplay);



               %d                               %                              d   deci-
mal number                                    %d
       integerToDisplay                 [5]

The value of the integer is 6.

                          %f     %d

[6]



                                                                                     21
BECOME AN XCODER                                               4


float x, floatToDisplay;
x = 12345.09876;
floatToDisplay = x/3.1416;
NSLog(@"The value of the float is %f.", floatToDisplay);



            .2       %        f

[7]
float x, floatToDisplay;
x = 12345.09876;
floatToDisplay = x/3.1416;
NSLog(@"The value of the float is %.2f.", floatToDisplay);




                 %    f           %   d


[8]
int x = 123456;
NSLog(@"%2d", x);
NSLog(@"%4d", x);
NSLog(@"%6d", x);
NSLog(@"%8d", x);

      [8]

123456
123456
123456
 123456

                 [8.1, 8.2]
                      [8.4]




[9]
float x = 1234.5678
NSLog(@"Reserve a space of 10, and show 2 significant digits.");
NSLog(@"%10.2d", x);


                                                                   22
BECOME AN XCODER                                                  4


                                                         [10.3]
             %d       %f               int float

[10]
int x = 8;
float pi = 3.1416;
NSLog(@"The integer value is %d, whereas the float value is %f.", x, pi);




    [10b]
    int x = 8;
    float pi = 3.1416;
    NSLog(@"The integer value is %f, whereas the float value is %f.", x, pi);



    The integer value is 0.000000, whereas the float value is 0.000000.

                                                                      NSLog()


             import        NSLog()

#import <Foundation/Foundation.h>




[11]
#import <Foundation/Foundation.h>
float circleArea(float theRadius);
float rectangleArea(float width, float height);


int main()
{
    float pictureWidth, pictureHeight, pictureSurfaceArea,
            circleRadius, circleSurfaceArea;
    pictureWidth      = 8.0;
    pictureHeight = 4.5;
    circleRadius      = 5.0;
    pictureSurfaceArea = rectangleArea(pictureWidth, pictureHeight);
    circleSurfaceArea      = circleArea(circleRadius);


                                                                                23
BECOME AN XCODER                                            4


    NSLog(@"Area of circle: %10.2f.", circleSurfaceArea);
    NSLog(@"Area of picture: %f. ", pictureSurfaceArea);
    return 0;
}


float circleArea(float theRadius)                 //
{
    float theArea;
    theArea = 3.1416 * theRadius * theRadius;
    return theArea;
}


float rectangleArea(float width, float height) //
{
    return width * height;
}




                                                                24
BECOME AN XCODER                                                        5




                                           5


                              Mac                      Mac
                       compiler                         Mac
           Apple         Xcode                                          Mac OS X
                          Xcode
http://developer.apple.com

            Xcode            Developer            Applications


                       Preferences                               File         New Pro-
ject




                                  Xcode


            Objective-C                         GUI                     Graphical User
Interface                                 Command Line Utility    Foundation Tool


                                                                                    25
BECOME AN XCODER                                                       5




                                     justatry
      Finish

                                        Terminal




                   "Groups & Files"
                                 GUI                                 GUI

               Xcode                            "Groups"

                Groups & Files                       justatry       Source
      justatry.m [1]                                            main()
          main()
                        justatry.m                                  Apple
  main()




                                                                             26
BECOME AN XCODER                                               5




                               Xcode    main()


[1]
#import <Foundation/Foundation.h>


int main (int argc, const char * argv[]) // [1.3]
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; // [1.5]


    // insert code here...
    NSLog(@"Hello, World!");
    [pool release]; //[1.9]
    return 0;
}



         NSLog()               import

       main()




                                                                            27
BECOME AN XCODER                                                                          5




             NSlog

        return 0;



                                                    main()                        [1.3]

                NSAutoreleasePool                            [1.5]

                              pool       release                     [1.9]




                          "          "
                                                                     main()
                                                                              [1]
                                                              [1.3   1.5       1.9]                Objective-
C


                                                                                          main



                                                                                          "pool"


              Apple                           [1]                    Build and Go
    build         compile




                                                    Build and Go


                                                                             Run Log
                     exited                    stopped                0                          main()
                                              [7.9]


                    [1]
    NSLog                        "        "


                                                                                                          28
BECOME AN XCODER                                                         5


[2]
#import <Foundation/Foundation.h>


int main (int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];


    // insert code here...
    NSLog(@"Julia is a pretty actress")           //
    [pool release];   //[2.9]
    return 0;
}

                                       Build                             [2.9]




                                    Xcode




error: parse error before "release".

        parse
                                                                             import
[2.1]                           #                          [2.8]
           [2.9]




                                               Apple               [1]           [3]

[3]
#import <Foundation/Foundation.h>


float circleArea(float theRadius);              // [3.3]




                                                                                       29
BECOME AN XCODER                                                           5


int main (int argc, const char * argv[])               // [3.5]
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int pictureWidth;
    float pictureHeight, pictureSurfaceArea,
          circleRadius, circleSurfaceArea;
    pictureWidth = 8;
    pictureHeight = 4.5;
    circleRadius = 5.0;
    pictureSurfaceArea =       pictureWidth * pictureHeight;
    circleSurfaceArea = circleArea(circleRadius);
    NSLog(@"Area of picture: %f.         Area of circle: %10.2f.",
          pictureSurfaceArea, circleSurfaceArea);
    [pool release];
    return 0;
}


float circleArea(float theRadius)                      // [3.22]
{
    float theArea;
    theArea = 3.1416 * theRadius * theRadius;
    return theArea;
}


float rectangleArea(float width, float height)              // [3.29]
{
    return width * height;
}

                                                       main()                    cir-
cleArea() [3.22]     rectangleArea() [3.29]
main()       [3.5]                            main()                     Apple




Area of picture: 36.000000.          Area of circle:            78.54.


justatry has exited with status 0.


                                                                                 30
BECOME AN XCODER                                             5




           Xcode
   Xcode              "        "   breakpoint




                          Build and Go          popup menu


    Build and Debug




                                                                 31
BECOME AN XCODER                                        5




                      Xcode debugger




Continue           debugger

                                             Mac OS X


Objective-C
                                       GUI




                                                            32
BECOME AN XCODER                                                                   6




                                                             6


                     [1.2]

[1]
int age = 42;
if (age > 30)                  //       >     "          "
{
     NSLog(@"age is older than thirty.");                        //[1.4]
}
NSLog(@"Finished."); //[1.6]

     [1.2]                   if...
                                             true
age > 30                             [1.4]
[1.6]                                               if

                                                                           if...else   [2]

[2]
int age = 42;
if (age > 30)
{
     NSLog(@"age is older than thirty.");                        //[2.4]
}
else
{
     NSLog(@"age is not older thirty.");                     //[2.7]
}
NSLog(@"Finished."); //[1.6]

         [2.7]                                                              [2]

             [2.2]

==

>


                                                                                             33
BECOME AN XCODER                                                              6


<

>=

<=

!=

                              -




                              if


     true             false

        Objective-C       true         false             1    0        BOOL
                                                "true"            1   YES         "false"
                0     NO
     [3]
     int x = 3;
     BOOL y;
     y = (x == 4);      // y             0



              AND                         &              &&
            OR                     |           ||

[4]
if ( (age >= 18) && (age < 65) )
{
     NSLog(@"Probably has to work for a living.");
}




[5]
if (age >= 18)
{

                                                                                            34
BECOME AN XCODER                                        6


    if (age < 65)
    {
        NSLog(@"Probably has to work for a living.");
    }
}




                                                            35
BECOME AN XCODER                                                               7           while




                                                     7
                                         while

                                   [1]

[1]
NSLog(@"Julia is a pretty actress.");
NSLog(@"Julia is a pretty actress.");
NSLog(@"Julia is a pretty actress.");



                     Objective-C

                                                                                     [2]
for
                     2.7

[2]
int x;
for (x = 1; x <= 10; x++)
{
    NSLog(@"Julia is a pretty actress.");
}
NSLog(@"The value of x is %d", x);

         [2]           [1.4]              10                   x         1
                   x <= 10                                                      x          1
                                    x                                          x++
          x                    2                     10                                            10
                                                 x        11         x <= 10
           [2.6]                          loop                     x   11          10

                                                 x++
                        [3]

[3]
float celsius, tempInFahrenheit;
for (tempInFahrenheit = 0; tempInFahrenheit <= 200; tempInFahrenheit =
tempInFahrenheit + 20)


                                                                                                        36
BECOME AN XCODER                                             7   while


{
    celsius = (tempInFahrenheit - 32.0) * 5.0 / 9.0;
    NSLog(@"%10.2f -> %10.2f", tempInFahrenheit, celsius);
}



       0.00 ->        -17.78
      20.00 ->         -6.67
      40.00 ->          4.44
      60.00 ->         15.56
      80.00 ->         26.67
    100.00 ->          37.78
    120.00 ->          48.89
    140.00 ->          60.00
    160.00 ->          71.11
    180.00 ->          82.22
    200.00 ->          93.33

Objective-C

while () { }



do {} while ()

                                for-loop
              false      loop

[4]
int counter = 1;
while (counter <= 10)
{
    NSLog(@"Julia is a pretty actress.n");
    counter = counter + 1;
}
NSLog(@"The value of counter is %d", counter);

                                           counter      11

          do {} while ()

[5]


                                                                         37
BECOME AN XCODER                                 7   while


int counter = 1;
do
{
     NSLog(@"Julia is a pretty actress.n");
     counter = counter + 1;
}
while (counter <= 10);


NSLog(@"The value of counter is %d", counter);

       counter       11


                                 GUI




                                                             38
BECOME AN XCODER                                          8                   (GUI)




                                     8
                                                     GUI
       Objective-C
 GUI                                       Objective-C                    C
                                            C         Objective-C     C
       "Objective"     Objective-C                             object

                                                    Objective-C




                                            Objective-C
                                                       Objective-C


                         Safari            Objective-C
                 Mac              Safari
                                                                              message




                                                                                      39
BECOME AN XCODER                                      8     (GUI)




                                   close



                                                          Safari




                          Safari              Apple

  a.

  b.                 template      Safari

            b                               class
                behave

 instance           76




                                                                    40
BECOME AN XCODER                                       8                         (GUI)


                           Mac                                             minimize
Dock




                                          access
                   close                           "       "
close                                                          methods




                                            RAM




                                 button                          text    field




                                               close




                                                                                         41
BECOME AN XCODER                                              8                 (GUI)


                                                                                        Mac




                                                         message sending expression




        Objective-C                              [1.1]             [1.2]

[1]
[receiver message];
[receiver message:argument];




                                                      [1.2]

                                         Xcode                              Application
  Cocoa Application                                               GUI
                      Xcode          Groups & Files                 Resources
MainMenu.nib          Double-click




                                                                                          42
BECOME AN XCODER                                           8              (GUI)




                              Xcode         MainMenu.nib


               Interface Builder                                                  File
         Hide Others                             "Window"
                                                               "Window"
          "Cocoa-"                              GUI
        "         " palettes window
              GUI       "Window"
            "System Font Text"                 GUI




                                      GUI




                                                                                   43
BECOME AN XCODER                                            8                  (GUI)


                                                                              NSButton
NSTextView            Apple


                 "Window"




                              properties                                command-shift-
i                                            "Window"                              In-
stances                                    command-shift-i
   pop-up menu             Attributes             Textured Window
                   brushed-steel look




                      Interface Builder                     inspector




  behavior
                            inherit                             Objective-C   C




                                                                                         44
BECOME AN XCODER                                                     8                       (GUI)


                                                   NSWindow


"close"


                                                                 "          "   superclass

hierarchy of inheritance



                                                                         Objective-C                 sig-
  nal                 error

                                                     implement
                    override

   Apple
                              Apple


                                        Apple                             close
                  invoke                               close
                                close                   recursive
  [2]
  //
  [super close]; //                        close




                              "NSObject"
           NSObject              subclass                 NSWindow                NSResponder
                              NSObject              NSObject




   MainMenu.nib                       Classes                                   NSObject
                           Classes             Subclass NSObject            MainMenu.nib
                                         "MAFoo"




                                                                                                       45
BECOME AN XCODER                                                8                   (GUI)




                                              MAFoo


  MAFoo                                 My Application



  NS                                    NS         Apple                     NextStep
  Apple        Next, Inc.       NextStep                       Mac OS X                 Steve
  Jobs

      CocoaDev      wiki
                             http://www.cocoadev.com/index.pl?ChooseYourOwnPrefix



                            Cocoa                                NSWindow
                                         NSColor                                      MAFoo




      Interface Builder             Classes         Instantiate MAFoo                       In-
stances                                         MAFoo




                                               MAFoo


                                                                                            46
BECOME AN XCODER                                                        8                 (GUI)


                                                                     MAFoo
                            MAFoo
                                                            reference
                                MAFoo                                                           MAFoo
                                                                            MAFoo




                                                     MAFoo
                MAFoo                   MAFoo           MAFoo
                     MAFoo                                          MAFoo                         trig-
ger            FAFoo




outlet


          MainFile.nib        Classes               MAFoo
      command-shift-i                   inspector                                   inspector
        Action            Add                              action                       MAFoo
                                                        "setTo5:"
                     5              Interface Builder
                         "reset:"                                                     0
                           ":"




                                                                                                   47
BECOME AN XCODER                                                  8        (GUI)




                                                 MAFoo


         inspector             Outlet                    outlet                    "text-
Field"




                                        outlet   MAFoo



                MAFoo                                5                "Set to 5"


                     "Reset"




                                                                                      48
BECOME AN XCODER                                             8             (GUI)




  a)       "Reset"      MAFoo

  b)       "Set to 5"    MAFoo

  c)   MAFoo

             MainFile.nib               Instances                      Control
       Reset         MaFoo
                                                 MAFoo




                                                 MAFoo


                          inspector                                MAFoo
                                      "reset:"           Connect




                                                                                   49
BECOME AN XCODER                                           8                  (GUI)




                                       inspector


                                      MAFoo                                 reset:


                           Set to 5                MAFoo

     MAFoo                                         MAFoo       control
                Connect




       MainMenu.nib        MAFoo                               Classes
                          MAFoo                                   Classes
Create Files for MAFoo      Interface Builder




                                                                                      50
BECOME AN XCODER                           8   (GUI)




                           MAFoo


                   Xcode                               Other
Sources
             Classes




                                   Xcode




                                                         51
BECOME AN XCODER                                              8                      (GUI)


                     4                                                   [11.1]


MAFoo.h                              header    file
                         [3.5]                NSObject
NSObject

[3]
/* MAFoo */


#import <Cocoa/Cocoa.h>              // [3.3]


@interface MAFoo : NSObject
{
    IBOutlet id textField; // [3.7]
}
- (IBAction)reset:(id)sender;
- (IBAction)setTo5:(id)sender;
@end

                [3.7]                           outlet "id"       "IB"            Interface Buil-
der

    IBAction [3.9   3.10]          void
                                 MAFoo

                                 Interface Builder Actions

                            #import <Foundation/Foundation.h>              [3.3]


                                              MAFoo.m

[4]
#import "MAFoo.h"


@implementation MAFoo


- (IBAction)reset:(id)sender // [4.5]
{
}




                                                                                              52
BECOME AN XCODER                                              8                  (GUI)


- (IBAction)setTo5:(id)sender
{
}


@end

         MAFoo.h
              reset:     setTo5:


MAFoo
                 Interface Builder            MAFoo
                MAFoo                                                 [5.7   5.12]

[5]
#import "MAFoo.h"


@implementation MAFoo


- (IBAction)reset:(id)sender
{
    [textField setIntValue:0]; // [5.7]
}


- (IBAction)setTo5:(id)sender
{
    [textField setIntValue:5]; // [5.12]
}


@end

                                           textField outlet
    Interface Builder       outlet
                                     setIntValue:                             setIntValue:


                                                              Xcode                      Build
and Go




                                                                                             53
BECOME AN XCODER   8   (GUI)




                               54
BECOME AN XCODER                                                          9




                                                 9


            Apple               setIntValue:



                                 Apple
                                         bug-free


    Interface Builder
                                                             "NSButton"
''System Font Text"                                  "NSTextField"
                        NSTextField

        Xcode                 Help->Documentation                         Cocoa
                "NSTextField"          API-Search
                                                                                  NSText-
Field

        NSTextField                      Class         NSTextField




                                                                                      55
BECOME AN XCODER                                      9




                          Xcode   Cocoa



NSObject

    Method Types

                                                  NSTextField
              NSControl                                  NSView
                          HTML                      Inherits from
           NSControl        NSControl

    NSControl
      Inherits from          NSView : NSResponder : NSObject


    Setting the control s value


    – setIntValue:


                                                                    56
BECOME AN XCODER                                                                9


                                                     setIntValue:

     setIntValue:


     - (void)setIntValue:(int)anInt

     Sets the value of the receiver’s cell (or selected cell) to
     the integer anInt. If the cell is being edited, it aborts all
     editing before setting the value; if the cell doesn’t inherit
     from NSActionCell, it marks the cell’s interior as needing to
     be redisplayed (NSActionCell performs its own updating of
     cells).
                               NSTextField
                                signature

    Objective-C
              void                                                                  setInt-
Value:         textField            MAFood
                                     (int)   anInt
                           5    0




                                 textField


      "          " Accessors
                  setIntValue:

  [1]
  - (int) intValue

                                                                    textfield


  [2]
  resultReceived = [textField intValue];




  Objective-C



                                                                                       57
BECOME AN XCODER                                      9




                                                                    "
   "   polymorphism             object-oriented programming

                            run-time


                      GUI                            setIntValue:




                                                                        58
BECOME AN XCODER                                                            10   awakeFromNib




                                             10
                               awakeFromNib
Apple


            framework                                    [12]          Foundation Kit
                                                                   Application Kit


                    GUI


                                            nib            nib            Next Interface Buil-
der                                         Application Kit
                                  Xcode     Help              Documentation

                              Full-Text Search
                                             Full-Text Search                               Ap-
plication Kit          Return      Xcode                                                Applica-
tion Kit Reference for Objective-C
Protocols                  NSNibAwakening

      NSNibAwaking
        Declared in                         AppKit/NSNibLoading.h
        Programming Topic                   Loading Resources

      Contents:
      Protocol Description
      Method Types
      Instance Methods

      Protocol Description
      This informal protocol consists of a single method, awakeFrom-
      Nib. Classes can implement this method to perform final ini-
      tialization of state after objects have been loaded from an
      Interface Builder archive.


                                                                                             59
BECOME AN XCODER                          10   awakeFromNib


                                    nib




    MAFoo.m [1.15]

[1]
#import "MAFoo.h"


@implementation MAFoo


- (IBAction)reset:(id)sender
{
    [textField setIntValue:0];
}


- (IBAction)setTo5:(id)sender
{
    [textField setIntValue:5];
}


- (void)awakeFromNib // [1.15]
{
    [textField setIntValue:0];
}


@end

                     awakeFromNib




                                                        60
BECOME AN XCODER                                                                                       11




                                                       11

                                                                C
                                                                              -                      pointer
                      -                  Objective-C

                                    Mac




[1]
int x = 4;

                            Mac
              x
                      [1]                                        int
                            x                                   long long         double


                  "x = 4"            4                                                                              x
                                                                          x                address
                                           x
                  x

              pointer

                                                       &                                                 x
                  &x

                      expression x             evaluate                            x
                  4                                   &x                               x




[2]
int *y;

                                y                                   int                                        y
          x                                        x        y

                                                                                                                   61
BECOME AN XCODER               11


[3]
y = &x;



*y

              4          "x"

*y = 5

              "x = 5"


                         1


[4]
void increment(int *y)
{
     *y = *y + 1;
}



[5]
int x = 4;
increment(&x);
//        x       5




                                    62
BECOME AN XCODER                                                                             12




                                                12

                                                  integer            long                  float
           double                        BOOL                                            pointer
                                string                              NSLog()
                                                                                 %
             %d

[1]
float piValue = 3.1416;
NSLog(@"Here are three examples of strings printed to the screen.n");
NSLog(@"Pi approximates %10.4f.n", piValue);
NSLog(@"The number of eyes of a dice is %d.n", 6);



NSString            NSMutableString                                                          NSString


[2]
NSString *favoriteComputer;
favoriteComputer = @"Mac!";
NSLog(favoriteComputer);

                                                            [2.1]
                                                                                                   11
  [2]

[3]
int *y;

                                 y                                               [2.1]
                       favoriteComputer                              NSString
                                                  Objective-C


                            @                                      Objective-C           C
              C                                             Objective-C
                                         Objective-C           @



                                                                                                   63
BECOME AN XCODER                                                              12


           Objective-C                      C                   Objective-C        Uni-
    code                            ASCII       Unicode


                                                          [4]

[4]
NSString *favoriteActress = @"Julia";

                 favoriteActress                                              "Julia"


                                      favoriteComputer
                             [5]                 NSString


[5]
#import <Foundation/Foundation.h>


int main (int argc, const char *argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];


    NSString *x;
    x = @"iBook";        // [5.7]
    x = @"MacBook Pro Intel"; //


    NSLog(x);
    [pool release];
    return 0;
}



MacBook Pro Intel

      NSString                                   immutable


                                                Objective-C




                                                                                        64
BECOME AN XCODER                                                            12




                                            NSMutableString


                                       length                     [6]

[6]
#import <Foundation/Foundation.h>


int main (int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int theLength;
    NSString * foo;


    foo = @"Julia!";
    theLength   = [foo length];   // [6.10]
    NSLog(@"The length is %d.", theLength);


    [pool release];
    return 0;
}



The length is 6.

                                            foo   bar
                                   x


      [6.10]           foo               length          length         NSString


      - (unsigned int)length
      Returns the number of Unicode characters in the receiver.

                                           [7]
uppercaseString
NSString


[7]


                                                                                   65
BECOME AN XCODER                                                  12


#import <Foundation/Foundation.h>


int main (int argc, const char * argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];


    NSString *foo, *bar;
    foo = @"Julia!";
    bar   = [foo uppercaseString];
    NSLog(@"%@ is converted into %@.", foo, bar);


    [pool release];
    return 0;
}



Julia! is converted into JULIA!



NSMutableString                           NSMutableString
                   appendString:

[8]
#import <Foundation/Foundation.h>


int main (int argc, const char * argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];


    NSMutableString *foo;                           // [8.7]
    foo = [@"Julia!" mutableCopy];                  // [8.8]
    [foo appendString:@" I am happy"];
    NSLog(@"Here is the result: %@.",    foo);


    [pool release];
    return 0;
}




                                                                       66
BECOME AN XCODER                                                                                  12


Here is the result: Julia! I am happy.

      [8.8]             mutableCopy                  NSString
                      mutable                                      [8.8]                  foo
                               "Julia!"

                                           Objective-C
                                                 [8.7]                                            Objective-
C             "   "                                           "                       "
                                                     "    "


      [8.7]                    foo                                         "Julia!"



                                            "foo"




                                     foo                          bar

bar = foo;

                               foo          bar


                                             "foo"




                                             "bar"




                         foo                                                          [foo dosomething];
        bar                            [bar dosomething];



[9]
#import <Foundation/Foundation.h>


                                                                                                         67
BECOME AN XCODER                                                  12




int main (int argc, const char * argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];


    NSMutableString *foo = [@"Julia!" mutableCopy];
    NSMutableString *bar = foo;


    NSLog(@"foo points to the string: %@.",   foo);
    NSLog(@"bar points to the string: %@.",   bar);
    NSLog(@"------------------------------");


    [foo appendString:@" I am happy"];


    NSLog(@"foo points to the string: %@.",   foo);
    NSLog(@"bar points to the string: %@.",   bar);


    [pool release];
    return 0;
}



foo points to the string: Julia!
bar points to the string: Julia!
------------------------------
foo points to the string: Julia! I am happy
bar points to the string: Julia! I am happy



                                                           8
                         MAFoo




                                                                       68
BECOME AN XCODER                                                                   13




                                           13


    array


            index
                    element

                              1
1




                              NSArray     NSMutableArray




[NSMutableArray array]

                                                           …       …
                                                  NSMutableArray


                                                  Objective-C
                                                  meta-classes
                                          Cocoa
"+"                                                       "-"          8   [4.5]
                                  array

       array
       + (id)array

                                                                                        69
BECOME AN XCODER                                                      13


      Creates and returns an empty array. This method is used by mu-
      table subclasses of NSArray.

      See Also: + arrayWithObject:, + arrayWithObjects:



[1]
#import <Foundation/Foundation.h>


int main (int argc, const char * argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];


    NSMutableArray *myArray = [NSMutableArray array];


    [myArray addObject:@"first string"];
    [myArray addObject:@"second string"];
    [myArray addObject:@"third string"];


    int count = [myArray count];


    NSLog(@"There are %d elements in my array", count);


    [pool release];
    return 0;
}



There are 3 elements in my array

                                                                  0
                      objectAtIndex:        [2.13]

[2]
#import <Foundation/Foundation.h>


int main (int argc, const char * argv[])
{


                                                                           70
BECOME AN XCODER                                                     13


    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];


    NSMutableArray *myArray = [NSMutableArray array];


    [myArray addObject:@"first string"];
    [myArray addObject:@"second string"];
    [myArray addObject:@"third string"];


    NSString *element = [myArray objectAtIndex:0];   // [2.13]


    NSLog(@"The element at index 0 in the array is: %@", element);


    [pool release];
    return 0;
}



The element at index 0 in the array is: first string




[3]
#import <Foundation/Foundation.h>


int main (int argc, const char * argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];


    NSMutableArray *myArray = [NSMutableArray array];


    [myArray addObject:@"first string"];
    [myArray addObject:@"second string"];
    [myArray addObject:@"third string"];


    int i;
    int count;




                                                                          71
BECOME AN XCODER                                                                              13


    for (i = 0, count = [myArray count]; i < count; i = i + 1)
    {
        NSString *element = [myArray objectAtIndex:i];
        NSLog(@"The element at index %d in the array is: %@", i, element);
    }


    [pool release];
    return 0;
}



The element at index 0 in the array is: first string
The element at index 1 in the array is: second string
The element at index 2 in the array is: third string




    NSArray         NSMutableArray


        replace
                   replaceObjectAtIndex:withObject:


                                                            Objective-C


    [4]
    [myArray replaceObjectAtIndex:1 withObject:@"Hello"];

                                      1               @"Hello"
                  valid


                              Objective-C


             "            "                                                   Smalltalk
    Objective-C                                                  expressive
                                           "                                              "
                                      Objective-C




                                                                                                   72
BECOME AN XCODER                                           14




                                      14


               Mac                   RAM



 free




 destroy




                                           Cocoa
                   "   "   retain count




                           1                           =
                                                   3




                           2




                           3




                                                                73
BECOME AN XCODER                                                                14


                                                retain
                                   release                   Cocoa                        "autore-
lease pool"                                                 release                   -
                                                                 autorelease pool
          autorelease                          autorelease pool                           release
                                                    autorelease pool
                autorelease pool

        Cocoa                                                                   reference count-
ing                                                       15            Cocoa
                   Apple                     Apple         Cocoa
          automatic garbage collection
                                 Apple


       Apple          2006         WWDC World Wide Developer Conference
                  2007             Xcode 3.0             automatic garbage collection
      Objective-C 2.0




                                                                                               74
BECOME AN XCODER                                                                 15




                                            15

                          Xcode             Objective-C




          Apple


                                                             Apple
http://www.apple.com/developer



http://osx.hyperjeff.net/reference/CocoaArticles.php
http://www.cocoadev.com
http://www.cocoabuilder.com
http://www.stepwise.com



http://lists.apple.com/mailman/listinfo/cocoa-dev                    cocoa-dev
  mailing list
                                            http://www.cocoabuilder.com


http://www.catb.org/~esr/faqs/smart-questions.html             "How To Ask Questions The
Smart   Way"               "            "         http://mis.ndhu.edu.tw/docu/
question.htm

                   Cocoa                Stephen Kochan    Programming in Objective-C

Big Nerd Ranch     Aaron Hillegass       Cocoa Programming for Mac OS X
Xcode                          James Duncan Davidson  Apple         O'Reilly          Cocoa
with Objective-C

                                  Mac
                                                     Apple
http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuid
elines/index.html



                                                                                        75
BECOME AN XCODER                15


                        Xcode        0

Bert, Alex, Philippe.




                                         76

More Related Content

Similar to Become an xcoder

GUI Programming with MacRuby
GUI Programming with MacRubyGUI Programming with MacRuby
GUI Programming with MacRubyErik Berlin
 
Projet d'accès aux résultats des étudiant via client mobile
Projet d'accès aux résultats des étudiant via client mobile Projet d'accès aux résultats des étudiant via client mobile
Projet d'accès aux résultats des étudiant via client mobile
Patrick Bashizi
 
Kubernetes in docker for mac
Kubernetes in docker for macKubernetes in docker for mac
Kubernetes in docker for mac
Catalin Jora
 
Webinar: Building Embedded Applications from QtCreator with Docker
Webinar: Building Embedded Applications from QtCreator with DockerWebinar: Building Embedded Applications from QtCreator with Docker
Webinar: Building Embedded Applications from QtCreator with Docker
Burkhard Stubert
 
Build and run embedded apps faster from qt creator with docker
Build and run embedded apps faster from qt creator with dockerBuild and run embedded apps faster from qt creator with docker
Build and run embedded apps faster from qt creator with docker
Qt
 
Academy PRO: Docker. Part 4
Academy PRO: Docker. Part 4Academy PRO: Docker. Part 4
Academy PRO: Docker. Part 4
Binary Studio
 
Replatforming Legacy Packaged Applications: Block-by-Block with Minecraft
Replatforming Legacy Packaged Applications: Block-by-Block with MinecraftReplatforming Legacy Packaged Applications: Block-by-Block with Minecraft
Replatforming Legacy Packaged Applications: Block-by-Block with Minecraft
VMware Tanzu
 
Weather data meets ibm cloud. part 4 analysis and visualization of weather ...
Weather data meets ibm cloud. part 4   analysis and visualization of weather ...Weather data meets ibm cloud. part 4   analysis and visualization of weather ...
Weather data meets ibm cloud. part 4 analysis and visualization of weather ...
Einar Karlsen
 
Oopp Lab Work
Oopp Lab WorkOopp Lab Work
Oopp Lab Work
Heather Dionne
 
BelfastJUG, Spring Boot + Docker
BelfastJUG, Spring Boot + DockerBelfastJUG, Spring Boot + Docker
BelfastJUG, Spring Boot + Docker
Hudson Mendes
 
Belfast JUG, Spring Boot & Docker
Belfast JUG, Spring Boot & DockerBelfast JUG, Spring Boot & Docker
Belfast JUG, Spring Boot & Docker
Hudson Mendes
 
Building high performance web applications
Building high performance web applicationsBuilding high performance web applications
Building high performance web applications
Maurice De Beijer [MVP]
 
Autocad Mep Gettingstarted
Autocad Mep GettingstartedAutocad Mep Gettingstarted
Autocad Mep Gettingstartedguestedb0170
 
Objective-C Runtime overview
Objective-C Runtime overviewObjective-C Runtime overview
Objective-C Runtime overview
Fantageek
 
mekentosj.com - building Papers
mekentosj.com - building Papersmekentosj.com - building Papers
mekentosj.com - building Papers
Alexander Griekspoor
 
EclipseCon 2016 - OCCIware : one Cloud API to rule them all
EclipseCon 2016 - OCCIware : one Cloud API to rule them allEclipseCon 2016 - OCCIware : one Cloud API to rule them all
EclipseCon 2016 - OCCIware : one Cloud API to rule them all
Marc Dutoo
 
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open WideOCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
OCCIware
 
Lecture 11 compiler ii
Lecture 11 compiler iiLecture 11 compiler ii
Lecture 11 compiler ii
鍾誠 陳鍾誠
 

Similar to Become an xcoder (20)

GUI Programming with MacRuby
GUI Programming with MacRubyGUI Programming with MacRuby
GUI Programming with MacRuby
 
Projet d'accès aux résultats des étudiant via client mobile
Projet d'accès aux résultats des étudiant via client mobile Projet d'accès aux résultats des étudiant via client mobile
Projet d'accès aux résultats des étudiant via client mobile
 
Kubernetes in docker for mac
Kubernetes in docker for macKubernetes in docker for mac
Kubernetes in docker for mac
 
tutorial
tutorialtutorial
tutorial
 
Webinar: Building Embedded Applications from QtCreator with Docker
Webinar: Building Embedded Applications from QtCreator with DockerWebinar: Building Embedded Applications from QtCreator with Docker
Webinar: Building Embedded Applications from QtCreator with Docker
 
Build and run embedded apps faster from qt creator with docker
Build and run embedded apps faster from qt creator with dockerBuild and run embedded apps faster from qt creator with docker
Build and run embedded apps faster from qt creator with docker
 
Academy PRO: Docker. Part 4
Academy PRO: Docker. Part 4Academy PRO: Docker. Part 4
Academy PRO: Docker. Part 4
 
Why MacRuby Matters
Why MacRuby MattersWhy MacRuby Matters
Why MacRuby Matters
 
Replatforming Legacy Packaged Applications: Block-by-Block with Minecraft
Replatforming Legacy Packaged Applications: Block-by-Block with MinecraftReplatforming Legacy Packaged Applications: Block-by-Block with Minecraft
Replatforming Legacy Packaged Applications: Block-by-Block with Minecraft
 
Weather data meets ibm cloud. part 4 analysis and visualization of weather ...
Weather data meets ibm cloud. part 4   analysis and visualization of weather ...Weather data meets ibm cloud. part 4   analysis and visualization of weather ...
Weather data meets ibm cloud. part 4 analysis and visualization of weather ...
 
Oopp Lab Work
Oopp Lab WorkOopp Lab Work
Oopp Lab Work
 
BelfastJUG, Spring Boot + Docker
BelfastJUG, Spring Boot + DockerBelfastJUG, Spring Boot + Docker
BelfastJUG, Spring Boot + Docker
 
Belfast JUG, Spring Boot & Docker
Belfast JUG, Spring Boot & DockerBelfast JUG, Spring Boot & Docker
Belfast JUG, Spring Boot & Docker
 
Building high performance web applications
Building high performance web applicationsBuilding high performance web applications
Building high performance web applications
 
Autocad Mep Gettingstarted
Autocad Mep GettingstartedAutocad Mep Gettingstarted
Autocad Mep Gettingstarted
 
Objective-C Runtime overview
Objective-C Runtime overviewObjective-C Runtime overview
Objective-C Runtime overview
 
mekentosj.com - building Papers
mekentosj.com - building Papersmekentosj.com - building Papers
mekentosj.com - building Papers
 
EclipseCon 2016 - OCCIware : one Cloud API to rule them all
EclipseCon 2016 - OCCIware : one Cloud API to rule them allEclipseCon 2016 - OCCIware : one Cloud API to rule them all
EclipseCon 2016 - OCCIware : one Cloud API to rule them all
 
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open WideOCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
 
Lecture 11 compiler ii
Lecture 11 compiler iiLecture 11 compiler ii
Lecture 11 compiler ii
 

More from Ivan lin

哎喔|品牌發展實戰技巧20230908.pdf
哎喔|品牌發展實戰技巧20230908.pdf哎喔|品牌發展實戰技巧20230908.pdf
哎喔|品牌發展實戰技巧20230908.pdf
Ivan lin
 
後 web2.0 社群新世代.行銷怎麼做?
後 web2.0 社群新世代.行銷怎麼做?後 web2.0 社群新世代.行銷怎麼做?
後 web2.0 社群新世代.行銷怎麼做?
Ivan lin
 
哎喔生活雜良|跨境品牌電商的心路歷程 & 日常經營分享
哎喔生活雜良|跨境品牌電商的心路歷程 & 日常經營分享哎喔生活雜良|跨境品牌電商的心路歷程 & 日常經營分享
哎喔生活雜良|跨境品牌電商的心路歷程 & 日常經營分享
Ivan lin
 
DTC品牌電商經營策略 20200820
DTC品牌電商經營策略 20200820DTC品牌電商經營策略 20200820
DTC品牌電商經營策略 20200820
Ivan lin
 
[成大企管營] 從離開台灣到回頭台南 - 我的二十年職涯路
[成大企管營] 從離開台灣到回頭台南 - 我的二十年職涯路[成大企管營] 從離開台灣到回頭台南 - 我的二十年職涯路
[成大企管營] 從離開台灣到回頭台南 - 我的二十年職涯路
Ivan lin
 
讓品牌飛得更遠 品牌再造之跨境經營分享
讓品牌飛得更遠 品牌再造之跨境經營分享讓品牌飛得更遠 品牌再造之跨境經營分享
讓品牌飛得更遠 品牌再造之跨境經營分享
Ivan lin
 
品牌的發展策略與社群行銷 Part. II 品牌的社群行銷 Social Marketing of Brand
品牌的發展策略與社群行銷 Part. II 品牌的社群行銷 Social Marketing of Brand品牌的發展策略與社群行銷 Part. II 品牌的社群行銷 Social Marketing of Brand
品牌的發展策略與社群行銷 Part. II 品牌的社群行銷 Social Marketing of Brand
Ivan lin
 
A backpack trip around the china (環遊中國背包客 2009年)
A backpack trip around the china (環遊中國背包客 2009年)A backpack trip around the china (環遊中國背包客 2009年)
A backpack trip around the china (環遊中國背包客 2009年)
Ivan lin
 
品牌的發展策略與社群行銷 - 在供過於求的年代建立一個銷售倍增的藍海策略 part.1
品牌的發展策略與社群行銷 - 在供過於求的年代建立一個銷售倍增的藍海策略 part.1品牌的發展策略與社群行銷 - 在供過於求的年代建立一個銷售倍增的藍海策略 part.1
品牌的發展策略與社群行銷 - 在供過於求的年代建立一個銷售倍增的藍海策略 part.1
Ivan lin
 
哎喔生活雜良 簡介企劃書
哎喔生活雜良 簡介企劃書哎喔生活雜良 簡介企劃書
哎喔生活雜良 簡介企劃書
Ivan lin
 
中國主要機場互動短片廣告方案
中國主要機場互動短片廣告方案中國主要機場互動短片廣告方案
中國主要機場互動短片廣告方案
Ivan lin
 
捷思唯數位整合服務體系介紹
捷思唯數位整合服務體系介紹捷思唯數位整合服務體系介紹
捷思唯數位整合服務體系介紹
Ivan lin
 
哎喔生活雜良 - 臺灣精品的跨境電商之路-1107
哎喔生活雜良 - 臺灣精品的跨境電商之路-1107哎喔生活雜良 - 臺灣精品的跨境電商之路-1107
哎喔生活雜良 - 臺灣精品的跨境電商之路-1107
Ivan lin
 
哎喔生活雜良 2017秋冬季刊- 生活刊物
哎喔生活雜良 2017秋冬季刊- 生活刊物哎喔生活雜良 2017秋冬季刊- 生活刊物
哎喔生活雜良 2017秋冬季刊- 生活刊物
Ivan lin
 
哎喔生活雜良 20170701 優質生活刊物
哎喔生活雜良 20170701 優質生活刊物哎喔生活雜良 20170701 優質生活刊物
哎喔生活雜良 20170701 優質生活刊物
Ivan lin
 
品牌電商如何布局國際 - 電商抬槓20170517
品牌電商如何布局國際 - 電商抬槓20170517品牌電商如何布局國際 - 電商抬槓20170517
品牌電商如何布局國際 - 電商抬槓20170517
Ivan lin
 
哎喔生活雜良 20170405 優質生活刊物
哎喔生活雜良 20170405 優質生活刊物哎喔生活雜良 20170405 優質生活刊物
哎喔生活雜良 20170405 優質生活刊物
Ivan lin
 
哎喔生活雜良 讓世界看見台灣的美好
哎喔生活雜良 讓世界看見台灣的美好哎喔生活雜良 讓世界看見台灣的美好
哎喔生活雜良 讓世界看見台灣的美好
Ivan lin
 
哎喔生活雜良 20161230 優質生活刊物
哎喔生活雜良 20161230 優質生活刊物哎喔生活雜良 20161230 優質生活刊物
哎喔生活雜良 20161230 優質生活刊物
Ivan lin
 
品牌管理入門課
品牌管理入門課 品牌管理入門課
品牌管理入門課
Ivan lin
 

More from Ivan lin (20)

哎喔|品牌發展實戰技巧20230908.pdf
哎喔|品牌發展實戰技巧20230908.pdf哎喔|品牌發展實戰技巧20230908.pdf
哎喔|品牌發展實戰技巧20230908.pdf
 
後 web2.0 社群新世代.行銷怎麼做?
後 web2.0 社群新世代.行銷怎麼做?後 web2.0 社群新世代.行銷怎麼做?
後 web2.0 社群新世代.行銷怎麼做?
 
哎喔生活雜良|跨境品牌電商的心路歷程 & 日常經營分享
哎喔生活雜良|跨境品牌電商的心路歷程 & 日常經營分享哎喔生活雜良|跨境品牌電商的心路歷程 & 日常經營分享
哎喔生活雜良|跨境品牌電商的心路歷程 & 日常經營分享
 
DTC品牌電商經營策略 20200820
DTC品牌電商經營策略 20200820DTC品牌電商經營策略 20200820
DTC品牌電商經營策略 20200820
 
[成大企管營] 從離開台灣到回頭台南 - 我的二十年職涯路
[成大企管營] 從離開台灣到回頭台南 - 我的二十年職涯路[成大企管營] 從離開台灣到回頭台南 - 我的二十年職涯路
[成大企管營] 從離開台灣到回頭台南 - 我的二十年職涯路
 
讓品牌飛得更遠 品牌再造之跨境經營分享
讓品牌飛得更遠 品牌再造之跨境經營分享讓品牌飛得更遠 品牌再造之跨境經營分享
讓品牌飛得更遠 品牌再造之跨境經營分享
 
品牌的發展策略與社群行銷 Part. II 品牌的社群行銷 Social Marketing of Brand
品牌的發展策略與社群行銷 Part. II 品牌的社群行銷 Social Marketing of Brand品牌的發展策略與社群行銷 Part. II 品牌的社群行銷 Social Marketing of Brand
品牌的發展策略與社群行銷 Part. II 品牌的社群行銷 Social Marketing of Brand
 
A backpack trip around the china (環遊中國背包客 2009年)
A backpack trip around the china (環遊中國背包客 2009年)A backpack trip around the china (環遊中國背包客 2009年)
A backpack trip around the china (環遊中國背包客 2009年)
 
品牌的發展策略與社群行銷 - 在供過於求的年代建立一個銷售倍增的藍海策略 part.1
品牌的發展策略與社群行銷 - 在供過於求的年代建立一個銷售倍增的藍海策略 part.1品牌的發展策略與社群行銷 - 在供過於求的年代建立一個銷售倍增的藍海策略 part.1
品牌的發展策略與社群行銷 - 在供過於求的年代建立一個銷售倍增的藍海策略 part.1
 
哎喔生活雜良 簡介企劃書
哎喔生活雜良 簡介企劃書哎喔生活雜良 簡介企劃書
哎喔生活雜良 簡介企劃書
 
中國主要機場互動短片廣告方案
中國主要機場互動短片廣告方案中國主要機場互動短片廣告方案
中國主要機場互動短片廣告方案
 
捷思唯數位整合服務體系介紹
捷思唯數位整合服務體系介紹捷思唯數位整合服務體系介紹
捷思唯數位整合服務體系介紹
 
哎喔生活雜良 - 臺灣精品的跨境電商之路-1107
哎喔生活雜良 - 臺灣精品的跨境電商之路-1107哎喔生活雜良 - 臺灣精品的跨境電商之路-1107
哎喔生活雜良 - 臺灣精品的跨境電商之路-1107
 
哎喔生活雜良 2017秋冬季刊- 生活刊物
哎喔生活雜良 2017秋冬季刊- 生活刊物哎喔生活雜良 2017秋冬季刊- 生活刊物
哎喔生活雜良 2017秋冬季刊- 生活刊物
 
哎喔生活雜良 20170701 優質生活刊物
哎喔生活雜良 20170701 優質生活刊物哎喔生活雜良 20170701 優質生活刊物
哎喔生活雜良 20170701 優質生活刊物
 
品牌電商如何布局國際 - 電商抬槓20170517
品牌電商如何布局國際 - 電商抬槓20170517品牌電商如何布局國際 - 電商抬槓20170517
品牌電商如何布局國際 - 電商抬槓20170517
 
哎喔生活雜良 20170405 優質生活刊物
哎喔生活雜良 20170405 優質生活刊物哎喔生活雜良 20170405 優質生活刊物
哎喔生活雜良 20170405 優質生活刊物
 
哎喔生活雜良 讓世界看見台灣的美好
哎喔生活雜良 讓世界看見台灣的美好哎喔生活雜良 讓世界看見台灣的美好
哎喔生活雜良 讓世界看見台灣的美好
 
哎喔生活雜良 20161230 優質生活刊物
哎喔生活雜良 20161230 優質生活刊物哎喔生活雜良 20161230 優質生活刊物
哎喔生活雜良 20161230 優質生活刊物
 
品牌管理入門課
品牌管理入門課 品牌管理入門課
品牌管理入門課
 

Recently uploaded

National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 

Recently uploaded (20)

National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 

Become an xcoder

  • 2. BECOME AN XCODER Copyright © 2006 by Bert Altenburg, Alex Clarke and Philippe Mougin. Version 1.2. Attribution: The licensors, Bert Altenburg, Alex Clarke and Philippe Mougin, permit others to copy, modify and distribute the work. In return, the licensees must give the original authors credit. Non-commercial: The licensors permit others to copy, modify and distribute the work and use the work in paid-for and free courses. In return, licensees may not sell the work itself, although it may accompany other work that is sold. 2
  • 3. BECOME AN XCODER __________________________________________________ 4 0 ______________________________________ 5 1 _____________________________ 7 2 __________________________ 13 3 ______________________________________________ 14 4 _______________________________________ 20 5 _____________________________________ 25 6 __________________________________________ 33 7 while _______________________________ 36 8 GUI ___________________ 39 9 _______________________________________ 55 10 awakeFromNib_____________________________________ 59 11 ______________________________________________ 61 12 ______________________________________________ 63 13 ______________________________________________ 69 14 _________________________________________ 73 15 __________________________________________ 75 3
  • 4. BECOME AN XCODER Apple Cocoa Xcode Mac OS X Apple Mac Objective-C Xcode (GUI) [4] [4.3] [4] volume = baseArea * height; // [4.3] Xcode 4
  • 5. BECOME AN XCODER 0 0 Mac Macintosh 1. Mac Mac Mac Mac Objective-C AppleScript AppleScript AppleScript for Absolute Starters http://www.macscripter.net/books 2. Macintosh PC Mac T Mac Mac Mac distributed computing, DC Folding@home SETI@home DC DC Mac DC Mac DC Mac Mac Mac DC DC http://distributedcomputing.info/projects.html 3. Macintosh 4. Macintosh 5
  • 6. BECOME AN XCODER 0 5. Macintosh DC 6
  • 7. BECOME AN XCODER 1 1 Xcode Objective-C 2+6= =3*4 * x y 2+6=x y=3*4 Objective-C Objective-C statement [1] x = 4; x 4 ... [1] compiler Mac 0 1 Mac 7
  • 8. BECOME AN XCODER 1 bug debugging x pictureWidth [2] [2] pictureWidth = 8; pictureWidth pictureWIDTH PictureWidth [2] Objective-C Objective-C pictureWidth "_" door8k do8or do_or door 8 8door Door8 [3] [3] pictureWidth=8; pictureHeight=6; pictureSurfaceArea=pictureWidth*pictureHeight; 8
  • 9. BECOME AN XCODER 1 [4] pictureWidth = 8; pictureHeight = 6; pictureSurfaceArea = pictureWidth * pictureHeight; [5] [5] pictureWidth = 8; pictureHeight = 4.5; pictureSurfaceArea = pictureWidth * pictureHeight; integers [5.1] [5.2] floating- point [5] " " [6] int pictureWidth; float pictureHeight, pictureSurfaceArea; pictureWidth = 8; pictureHeight = 4.5; pictureSurfaceArea = pictureWidth * pictureHeight; [6.1] int pictureWidth integer [6.2] float pictureWidth int float pictureSur- faceArea [6.2] int float int float long long double 9
  • 10. BECOME AN XCODER 1 [7] unsigned int chocolateBarsInStock; unsigned int unsigned int [8] [8] int x = 10; float y= 3.5, z = 42; operators + - / * Objective-C x = x + 1; [9] [10] [9] x++; [10] ++x; x ++ [11] [12] [11] x = 10; 10
  • 11. BECOME AN XCODER 1 y = 2 * (x++); [12] x = 10; y = 2 * (++x); [11] y 20 x 11 [12.2] x 2 1 x 11 y 22 [12] [13] [13] x = 10; x++; y = 2 * x; * / + - 2*3+4 10 2 * (3 + 4) 14 [14, 15] [14] int x = 5, y = 12, ratio; ratio = y / x; [15] float x = 5, y = 12, ratio; ratio = y / x; [14] 2 [15] 2.4 % % operand % [16] int x = 13, y = 5, remainder; remainder = x % y; 11
  • 12. BECOME AN XCODER 1 remainder 3 x 2*y + 3 21 % 7 0 30 % 2 0 50 % 9 5 22 % 7 1 31 % 2 1 60 % 29 2 23 % 7 2 32 % 2 0 24 % 7 3 33 % 2 1 27 % 7 6 34 % 2 0 12
  • 13. BECOME AN XCODER 2 2 [1] [1] float pictureWidth, pictureHeight, pictureSurfaceArea; pictureWidth = 8.0; pictureHeight = 4.5; pictureSurfaceArea = pictureWidth * pictureHeight; // Xcode /* */ /* */ Xcode outcomment /* */ 13
  • 14. BECOME AN XCODER 3 3 Objective-C function main() main() main() [1] [1] main() { // main() } [1.1] "main" "main" main() [1.2,1.5] [2] [2] main() { // float pictureWidth, pictureHeight, pictureSurfaceArea; // 14
  • 15. BECOME AN XCODER 3 pictureWidth = 8.0; pictureHeight = 4.5; // pictureSurfaceArea = pictureWidth * pictureHeight; } main() main() circleArea() [3] [3] main() { float pictureWidth, pictureHeight, pictureSurfaceArea; pictureWidth = 8.0; pictureHeight = 4.5; pictureSurfaceArea = pictureWidth * pictureHeight; } circleArea() // [3.9] { } [3.9] main() circleArea() main() [4] [4] main() { float pictureWidth, pictureHeight, pictureSurfaceArea, circleRadius, circleSurfaceArea; // [4.4] pictureWidth = 8.0; pictureHeight = 4.5; circleRadius = 5.0; // [4.7] pictureSurfaceArea = pictureWidth * pictureHeight; 15
  • 16. BECOME AN XCODER 3 // circleSurfaceArea = circleArea(circleRadius); // [4.11] } [3] float [4.4] initialize circleRadius [4.7] [4.11] circleArea() circleRadius circleArea() argument circleRadius circleArea() circleArea() return [3] circleArea() [5] circleArea() [5] circleArea(float theRadius) // [5.1] { float theArea; // pi r theArea = 3.1416 * theRadius * theRadius; //[5.5] return theArea; } [5.1] circleArea() theRadius theArea [5.5] [5.3] main [4.4] theRadius [5.1] [5.6] [4.11] circleSurfaceArea [5] float [6.1] [6] float circleArea(float theRadius) { float theArea; theArea = 3.1416 * theRadius * theRadius; return theArea; } 16
  • 17. BECOME AN XCODER 3 [6.1] theArea float main() circleSurfaceArea [4.11] [7] int throwDice() { int noOfEyes; // 1 6 return noOfEyes; } “void” “return” return [8] void beepXTimes(int x); { // x return; } pictureSurfaceArea() [9] float pictureSurfaceArea(float theWidth, float theHeight) { // } main() return 0 [10.10] main() main() "int" [10.1] [10] 17
  • 18. BECOME AN XCODER 3 int main() { float pictureWidth, pictureHeight, pictureSurfaceArea, circleRadius, circleSurfaceArea; pictureWidth = 8; pictureHeight = 4.5; circleRadius = 5.0; pictureSurfaceArea = pictureWidth * pictureHeight; circleSurfaceArea = circleArea(circleRadius); return 0; // [10.10] } float circleArea(float theRadius) // [10.13] { float theArea; theArea = 3.1416 * theRadius * theRadius; return theArea; } [10] [10.1] main() [10.13] [10.9] circleArea() main() warning int main() function declaration [11.1] [10.13] [11] float circleArea(float theRadius); // int main() { [10] rectangleArea() [12] main() 18
  • 19. BECOME AN XCODER 3 main() [12] float rectangleArea(float length, float width) { return (length * width); } [12.3] [10.15] theArea [12] rectangleArea float float [12.1] Objective-C Xcode [11] 19
  • 20. BECOME AN XCODER 4 4 Cocoa NSLog() " " NSLog() Cocoa NSLog() [1] int main() { NSLog(@"Julia is a pretty actress."); return 0; } [1] "Julia is a pretty actress." @" " string NSLog() [1] 2005-12-22 17:39:23.084 test[399] Julia is a pretty actress. character main() [2] NSLog(@""); NSLog(@" "); [2.1] empty string [2.2] space 1 20
  • 21. BECOME AN XCODER 4 [3.1] n [3] NSLog(@"Julia is a pretty nactress."); Julia is a pretty actress. [3.1] escape NSLog() "n" " " NSLog() [4] NSLog(@"Julia is a pretty actress.n"); [4.1] Julia is a pretty actress.n [5] int x, integerToDisplay; x = 1; integerToDisplay = 5 + x; NSLog(@"The value of the integer is %d.", integerToDisplay); %d % d deci- mal number %d integerToDisplay [5] The value of the integer is 6. %f %d [6] 21
  • 22. BECOME AN XCODER 4 float x, floatToDisplay; x = 12345.09876; floatToDisplay = x/3.1416; NSLog(@"The value of the float is %f.", floatToDisplay); .2 % f [7] float x, floatToDisplay; x = 12345.09876; floatToDisplay = x/3.1416; NSLog(@"The value of the float is %.2f.", floatToDisplay); % f % d [8] int x = 123456; NSLog(@"%2d", x); NSLog(@"%4d", x); NSLog(@"%6d", x); NSLog(@"%8d", x); [8] 123456 123456 123456 123456 [8.1, 8.2] [8.4] [9] float x = 1234.5678 NSLog(@"Reserve a space of 10, and show 2 significant digits."); NSLog(@"%10.2d", x); 22
  • 23. BECOME AN XCODER 4 [10.3] %d %f int float [10] int x = 8; float pi = 3.1416; NSLog(@"The integer value is %d, whereas the float value is %f.", x, pi); [10b] int x = 8; float pi = 3.1416; NSLog(@"The integer value is %f, whereas the float value is %f.", x, pi); The integer value is 0.000000, whereas the float value is 0.000000. NSLog() import NSLog() #import <Foundation/Foundation.h> [11] #import <Foundation/Foundation.h> float circleArea(float theRadius); float rectangleArea(float width, float height); int main() { float pictureWidth, pictureHeight, pictureSurfaceArea, circleRadius, circleSurfaceArea; pictureWidth = 8.0; pictureHeight = 4.5; circleRadius = 5.0; pictureSurfaceArea = rectangleArea(pictureWidth, pictureHeight); circleSurfaceArea = circleArea(circleRadius); 23
  • 24. BECOME AN XCODER 4 NSLog(@"Area of circle: %10.2f.", circleSurfaceArea); NSLog(@"Area of picture: %f. ", pictureSurfaceArea); return 0; } float circleArea(float theRadius) // { float theArea; theArea = 3.1416 * theRadius * theRadius; return theArea; } float rectangleArea(float width, float height) // { return width * height; } 24
  • 25. BECOME AN XCODER 5 5 Mac Mac compiler Mac Apple Xcode Mac OS X Xcode http://developer.apple.com Xcode Developer Applications Preferences File New Pro- ject Xcode Objective-C GUI Graphical User Interface Command Line Utility Foundation Tool 25
  • 26. BECOME AN XCODER 5 justatry Finish Terminal "Groups & Files" GUI GUI Xcode "Groups" Groups & Files justatry Source justatry.m [1] main() main() justatry.m Apple main() 26
  • 27. BECOME AN XCODER 5 Xcode main() [1] #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) // [1.3] { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; // [1.5] // insert code here... NSLog(@"Hello, World!"); [pool release]; //[1.9] return 0; } NSLog() import main() 27
  • 28. BECOME AN XCODER 5 NSlog return 0; main() [1.3] NSAutoreleasePool [1.5] pool release [1.9] " " main() [1] [1.3 1.5 1.9] Objective- C main "pool" Apple [1] Build and Go build compile Build and Go Run Log exited stopped 0 main() [7.9] [1] NSLog " " 28
  • 29. BECOME AN XCODER 5 [2] #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; // insert code here... NSLog(@"Julia is a pretty actress") // [pool release]; //[2.9] return 0; } Build [2.9] Xcode error: parse error before "release". parse import [2.1] # [2.8] [2.9] Apple [1] [3] [3] #import <Foundation/Foundation.h> float circleArea(float theRadius); // [3.3] 29
  • 30. BECOME AN XCODER 5 int main (int argc, const char * argv[]) // [3.5] { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int pictureWidth; float pictureHeight, pictureSurfaceArea, circleRadius, circleSurfaceArea; pictureWidth = 8; pictureHeight = 4.5; circleRadius = 5.0; pictureSurfaceArea = pictureWidth * pictureHeight; circleSurfaceArea = circleArea(circleRadius); NSLog(@"Area of picture: %f. Area of circle: %10.2f.", pictureSurfaceArea, circleSurfaceArea); [pool release]; return 0; } float circleArea(float theRadius) // [3.22] { float theArea; theArea = 3.1416 * theRadius * theRadius; return theArea; } float rectangleArea(float width, float height) // [3.29] { return width * height; } main() cir- cleArea() [3.22] rectangleArea() [3.29] main() [3.5] main() Apple Area of picture: 36.000000. Area of circle: 78.54. justatry has exited with status 0. 30
  • 31. BECOME AN XCODER 5 Xcode Xcode " " breakpoint Build and Go popup menu Build and Debug 31
  • 32. BECOME AN XCODER 5 Xcode debugger Continue debugger Mac OS X Objective-C GUI 32
  • 33. BECOME AN XCODER 6 6 [1.2] [1] int age = 42; if (age > 30) // > " " { NSLog(@"age is older than thirty."); //[1.4] } NSLog(@"Finished."); //[1.6] [1.2] if... true age > 30 [1.4] [1.6] if if...else [2] [2] int age = 42; if (age > 30) { NSLog(@"age is older than thirty."); //[2.4] } else { NSLog(@"age is not older thirty."); //[2.7] } NSLog(@"Finished."); //[1.6] [2.7] [2] [2.2] == > 33
  • 34. BECOME AN XCODER 6 < >= <= != - if true false Objective-C true false 1 0 BOOL "true" 1 YES "false" 0 NO [3] int x = 3; BOOL y; y = (x == 4); // y 0 AND & && OR | || [4] if ( (age >= 18) && (age < 65) ) { NSLog(@"Probably has to work for a living."); } [5] if (age >= 18) { 34
  • 35. BECOME AN XCODER 6 if (age < 65) { NSLog(@"Probably has to work for a living."); } } 35
  • 36. BECOME AN XCODER 7 while 7 while [1] [1] NSLog(@"Julia is a pretty actress."); NSLog(@"Julia is a pretty actress."); NSLog(@"Julia is a pretty actress."); Objective-C [2] for 2.7 [2] int x; for (x = 1; x <= 10; x++) { NSLog(@"Julia is a pretty actress."); } NSLog(@"The value of x is %d", x); [2] [1.4] 10 x 1 x <= 10 x 1 x x++ x 2 10 10 x 11 x <= 10 [2.6] loop x 11 10 x++ [3] [3] float celsius, tempInFahrenheit; for (tempInFahrenheit = 0; tempInFahrenheit <= 200; tempInFahrenheit = tempInFahrenheit + 20) 36
  • 37. BECOME AN XCODER 7 while { celsius = (tempInFahrenheit - 32.0) * 5.0 / 9.0; NSLog(@"%10.2f -> %10.2f", tempInFahrenheit, celsius); } 0.00 -> -17.78 20.00 -> -6.67 40.00 -> 4.44 60.00 -> 15.56 80.00 -> 26.67 100.00 -> 37.78 120.00 -> 48.89 140.00 -> 60.00 160.00 -> 71.11 180.00 -> 82.22 200.00 -> 93.33 Objective-C while () { } do {} while () for-loop false loop [4] int counter = 1; while (counter <= 10) { NSLog(@"Julia is a pretty actress.n"); counter = counter + 1; } NSLog(@"The value of counter is %d", counter); counter 11 do {} while () [5] 37
  • 38. BECOME AN XCODER 7 while int counter = 1; do { NSLog(@"Julia is a pretty actress.n"); counter = counter + 1; } while (counter <= 10); NSLog(@"The value of counter is %d", counter); counter 11 GUI 38
  • 39. BECOME AN XCODER 8 (GUI) 8 GUI Objective-C GUI Objective-C C C Objective-C C "Objective" Objective-C object Objective-C Objective-C Objective-C Safari Objective-C Mac Safari message 39
  • 40. BECOME AN XCODER 8 (GUI) close Safari Safari Apple a. b. template Safari b class behave instance 76 40
  • 41. BECOME AN XCODER 8 (GUI) Mac minimize Dock access close " " close methods RAM button text field close 41
  • 42. BECOME AN XCODER 8 (GUI) Mac message sending expression Objective-C [1.1] [1.2] [1] [receiver message]; [receiver message:argument]; [1.2] Xcode Application Cocoa Application GUI Xcode Groups & Files Resources MainMenu.nib Double-click 42
  • 43. BECOME AN XCODER 8 (GUI) Xcode MainMenu.nib Interface Builder File Hide Others "Window" "Window" "Cocoa-" GUI " " palettes window GUI "Window" "System Font Text" GUI GUI 43
  • 44. BECOME AN XCODER 8 (GUI) NSButton NSTextView Apple "Window" properties command-shift- i "Window" In- stances command-shift-i pop-up menu Attributes Textured Window brushed-steel look Interface Builder inspector behavior inherit Objective-C C 44
  • 45. BECOME AN XCODER 8 (GUI) NSWindow "close" " " superclass hierarchy of inheritance Objective-C sig- nal error implement override Apple Apple Apple close invoke close close recursive [2] // [super close]; // close "NSObject" NSObject subclass NSWindow NSResponder NSObject NSObject MainMenu.nib Classes NSObject Classes Subclass NSObject MainMenu.nib "MAFoo" 45
  • 46. BECOME AN XCODER 8 (GUI) MAFoo MAFoo My Application NS NS Apple NextStep Apple Next, Inc. NextStep Mac OS X Steve Jobs CocoaDev wiki http://www.cocoadev.com/index.pl?ChooseYourOwnPrefix Cocoa NSWindow NSColor MAFoo Interface Builder Classes Instantiate MAFoo In- stances MAFoo MAFoo 46
  • 47. BECOME AN XCODER 8 (GUI) MAFoo MAFoo reference MAFoo MAFoo MAFoo MAFoo MAFoo MAFoo MAFoo MAFoo MAFoo trig- ger FAFoo outlet MainFile.nib Classes MAFoo command-shift-i inspector inspector Action Add action MAFoo "setTo5:" 5 Interface Builder "reset:" 0 ":" 47
  • 48. BECOME AN XCODER 8 (GUI) MAFoo inspector Outlet outlet "text- Field" outlet MAFoo MAFoo 5 "Set to 5" "Reset" 48
  • 49. BECOME AN XCODER 8 (GUI) a) "Reset" MAFoo b) "Set to 5" MAFoo c) MAFoo MainFile.nib Instances Control Reset MaFoo MAFoo MAFoo inspector MAFoo "reset:" Connect 49
  • 50. BECOME AN XCODER 8 (GUI) inspector MAFoo reset: Set to 5 MAFoo MAFoo MAFoo control Connect MainMenu.nib MAFoo Classes MAFoo Classes Create Files for MAFoo Interface Builder 50
  • 51. BECOME AN XCODER 8 (GUI) MAFoo Xcode Other Sources Classes Xcode 51
  • 52. BECOME AN XCODER 8 (GUI) 4 [11.1] MAFoo.h header file [3.5] NSObject NSObject [3] /* MAFoo */ #import <Cocoa/Cocoa.h> // [3.3] @interface MAFoo : NSObject { IBOutlet id textField; // [3.7] } - (IBAction)reset:(id)sender; - (IBAction)setTo5:(id)sender; @end [3.7] outlet "id" "IB" Interface Buil- der IBAction [3.9 3.10] void MAFoo Interface Builder Actions #import <Foundation/Foundation.h> [3.3] MAFoo.m [4] #import "MAFoo.h" @implementation MAFoo - (IBAction)reset:(id)sender // [4.5] { } 52
  • 53. BECOME AN XCODER 8 (GUI) - (IBAction)setTo5:(id)sender { } @end MAFoo.h reset: setTo5: MAFoo Interface Builder MAFoo MAFoo [5.7 5.12] [5] #import "MAFoo.h" @implementation MAFoo - (IBAction)reset:(id)sender { [textField setIntValue:0]; // [5.7] } - (IBAction)setTo5:(id)sender { [textField setIntValue:5]; // [5.12] } @end textField outlet Interface Builder outlet setIntValue: setIntValue: Xcode Build and Go 53
  • 54. BECOME AN XCODER 8 (GUI) 54
  • 55. BECOME AN XCODER 9 9 Apple setIntValue: Apple bug-free Interface Builder "NSButton" ''System Font Text" "NSTextField" NSTextField Xcode Help->Documentation Cocoa "NSTextField" API-Search NSText- Field NSTextField Class NSTextField 55
  • 56. BECOME AN XCODER 9 Xcode Cocoa NSObject Method Types NSTextField NSControl NSView HTML Inherits from NSControl NSControl NSControl Inherits from NSView : NSResponder : NSObject Setting the control s value – setIntValue: 56
  • 57. BECOME AN XCODER 9 setIntValue: setIntValue: - (void)setIntValue:(int)anInt Sets the value of the receiver’s cell (or selected cell) to the integer anInt. If the cell is being edited, it aborts all editing before setting the value; if the cell doesn’t inherit from NSActionCell, it marks the cell’s interior as needing to be redisplayed (NSActionCell performs its own updating of cells). NSTextField signature Objective-C void setInt- Value: textField MAFood (int) anInt 5 0 textField " " Accessors setIntValue: [1] - (int) intValue textfield [2] resultReceived = [textField intValue]; Objective-C 57
  • 58. BECOME AN XCODER 9 " " polymorphism object-oriented programming run-time GUI setIntValue: 58
  • 59. BECOME AN XCODER 10 awakeFromNib 10 awakeFromNib Apple framework [12] Foundation Kit Application Kit GUI nib nib Next Interface Buil- der Application Kit Xcode Help Documentation Full-Text Search Full-Text Search Ap- plication Kit Return Xcode Applica- tion Kit Reference for Objective-C Protocols NSNibAwakening NSNibAwaking Declared in AppKit/NSNibLoading.h Programming Topic Loading Resources Contents: Protocol Description Method Types Instance Methods Protocol Description This informal protocol consists of a single method, awakeFrom- Nib. Classes can implement this method to perform final ini- tialization of state after objects have been loaded from an Interface Builder archive. 59
  • 60. BECOME AN XCODER 10 awakeFromNib nib MAFoo.m [1.15] [1] #import "MAFoo.h" @implementation MAFoo - (IBAction)reset:(id)sender { [textField setIntValue:0]; } - (IBAction)setTo5:(id)sender { [textField setIntValue:5]; } - (void)awakeFromNib // [1.15] { [textField setIntValue:0]; } @end awakeFromNib 60
  • 61. BECOME AN XCODER 11 11 C - pointer - Objective-C Mac [1] int x = 4; Mac x [1] int x long long double "x = 4" 4 x x address x x pointer & x &x expression x evaluate x 4 &x x [2] int *y; y int y x x y 61
  • 62. BECOME AN XCODER 11 [3] y = &x; *y 4 "x" *y = 5 "x = 5" 1 [4] void increment(int *y) { *y = *y + 1; } [5] int x = 4; increment(&x); // x 5 62
  • 63. BECOME AN XCODER 12 12 integer long float double BOOL pointer string NSLog() % %d [1] float piValue = 3.1416; NSLog(@"Here are three examples of strings printed to the screen.n"); NSLog(@"Pi approximates %10.4f.n", piValue); NSLog(@"The number of eyes of a dice is %d.n", 6); NSString NSMutableString NSString [2] NSString *favoriteComputer; favoriteComputer = @"Mac!"; NSLog(favoriteComputer); [2.1] 11 [2] [3] int *y; y [2.1] favoriteComputer NSString Objective-C @ Objective-C C C Objective-C Objective-C @ 63
  • 64. BECOME AN XCODER 12 Objective-C C Objective-C Uni- code ASCII Unicode [4] [4] NSString *favoriteActress = @"Julia"; favoriteActress "Julia" favoriteComputer [5] NSString [5] #import <Foundation/Foundation.h> int main (int argc, const char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSString *x; x = @"iBook"; // [5.7] x = @"MacBook Pro Intel"; // NSLog(x); [pool release]; return 0; } MacBook Pro Intel NSString immutable Objective-C 64
  • 65. BECOME AN XCODER 12 NSMutableString length [6] [6] #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int theLength; NSString * foo; foo = @"Julia!"; theLength = [foo length]; // [6.10] NSLog(@"The length is %d.", theLength); [pool release]; return 0; } The length is 6. foo bar x [6.10] foo length length NSString - (unsigned int)length Returns the number of Unicode characters in the receiver. [7] uppercaseString NSString [7] 65
  • 66. BECOME AN XCODER 12 #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *foo, *bar; foo = @"Julia!"; bar = [foo uppercaseString]; NSLog(@"%@ is converted into %@.", foo, bar); [pool release]; return 0; } Julia! is converted into JULIA! NSMutableString NSMutableString appendString: [8] #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSMutableString *foo; // [8.7] foo = [@"Julia!" mutableCopy]; // [8.8] [foo appendString:@" I am happy"]; NSLog(@"Here is the result: %@.", foo); [pool release]; return 0; } 66
  • 67. BECOME AN XCODER 12 Here is the result: Julia! I am happy. [8.8] mutableCopy NSString mutable [8.8] foo "Julia!" Objective-C [8.7] Objective- C " " " " " " [8.7] foo "Julia!" "foo" foo bar bar = foo; foo bar "foo" "bar" foo [foo dosomething]; bar [bar dosomething]; [9] #import <Foundation/Foundation.h> 67
  • 68. BECOME AN XCODER 12 int main (int argc, const char * argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSMutableString *foo = [@"Julia!" mutableCopy]; NSMutableString *bar = foo; NSLog(@"foo points to the string: %@.", foo); NSLog(@"bar points to the string: %@.", bar); NSLog(@"------------------------------"); [foo appendString:@" I am happy"]; NSLog(@"foo points to the string: %@.", foo); NSLog(@"bar points to the string: %@.", bar); [pool release]; return 0; } foo points to the string: Julia! bar points to the string: Julia! ------------------------------ foo points to the string: Julia! I am happy bar points to the string: Julia! I am happy 8 MAFoo 68
  • 69. BECOME AN XCODER 13 13 array index element 1 1 NSArray NSMutableArray [NSMutableArray array] … … NSMutableArray Objective-C meta-classes Cocoa "+" "-" 8 [4.5] array array + (id)array 69
  • 70. BECOME AN XCODER 13 Creates and returns an empty array. This method is used by mu- table subclasses of NSArray. See Also: + arrayWithObject:, + arrayWithObjects: [1] #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSMutableArray *myArray = [NSMutableArray array]; [myArray addObject:@"first string"]; [myArray addObject:@"second string"]; [myArray addObject:@"third string"]; int count = [myArray count]; NSLog(@"There are %d elements in my array", count); [pool release]; return 0; } There are 3 elements in my array 0 objectAtIndex: [2.13] [2] #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { 70
  • 71. BECOME AN XCODER 13 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSMutableArray *myArray = [NSMutableArray array]; [myArray addObject:@"first string"]; [myArray addObject:@"second string"]; [myArray addObject:@"third string"]; NSString *element = [myArray objectAtIndex:0]; // [2.13] NSLog(@"The element at index 0 in the array is: %@", element); [pool release]; return 0; } The element at index 0 in the array is: first string [3] #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSMutableArray *myArray = [NSMutableArray array]; [myArray addObject:@"first string"]; [myArray addObject:@"second string"]; [myArray addObject:@"third string"]; int i; int count; 71
  • 72. BECOME AN XCODER 13 for (i = 0, count = [myArray count]; i < count; i = i + 1) { NSString *element = [myArray objectAtIndex:i]; NSLog(@"The element at index %d in the array is: %@", i, element); } [pool release]; return 0; } The element at index 0 in the array is: first string The element at index 1 in the array is: second string The element at index 2 in the array is: third string NSArray NSMutableArray replace replaceObjectAtIndex:withObject: Objective-C [4] [myArray replaceObjectAtIndex:1 withObject:@"Hello"]; 1 @"Hello" valid Objective-C " " Smalltalk Objective-C expressive " " Objective-C 72
  • 73. BECOME AN XCODER 14 14 Mac RAM free destroy Cocoa " " retain count 1 = 3 2 3 73
  • 74. BECOME AN XCODER 14 retain release Cocoa "autore- lease pool" release - autorelease pool autorelease autorelease pool release autorelease pool autorelease pool Cocoa reference count- ing 15 Cocoa Apple Apple Cocoa automatic garbage collection Apple Apple 2006 WWDC World Wide Developer Conference 2007 Xcode 3.0 automatic garbage collection Objective-C 2.0 74
  • 75. BECOME AN XCODER 15 15 Xcode Objective-C Apple Apple http://www.apple.com/developer http://osx.hyperjeff.net/reference/CocoaArticles.php http://www.cocoadev.com http://www.cocoabuilder.com http://www.stepwise.com http://lists.apple.com/mailman/listinfo/cocoa-dev cocoa-dev mailing list http://www.cocoabuilder.com http://www.catb.org/~esr/faqs/smart-questions.html "How To Ask Questions The Smart Way" " " http://mis.ndhu.edu.tw/docu/ question.htm Cocoa Stephen Kochan Programming in Objective-C Big Nerd Ranch Aaron Hillegass Cocoa Programming for Mac OS X Xcode James Duncan Davidson Apple O'Reilly Cocoa with Objective-C Mac Apple http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuid elines/index.html 75
  • 76. BECOME AN XCODER 15 Xcode 0 Bert, Alex, Philippe. 76