SlideShare a Scribd company logo
1 of 84
Introduction to iOS Programming




                           Dr. Thanisa Kruawaisayawan
                                  www.imcinstitute.com
Get Started

• What are needed?


  • Tools:


     • Computer with Mac OSX (Intel based and Mountain Lion)


     • Xcode 4.5.2


     • iOS Developer Program (optional)


  • Knowledge and Creativity


  • Time
                                                               2
iOS Developer Programs

• iOS Developer Program ($99/year)


   • To distribute apps on the App Store as an individual, sole proprietor, company or
     organization (up to 100 registered devices)


• iOS Developer Enterprise Program ($299/year)

   • To develop proprietary apps for internal distribution within your company,
     organization, government entity or educational institution


• iOS Developer University Program (Free)


   • To introduce iOS development into curriculum (up to 200 students)


                                                                                         3
iOS > Application > Single View Application




                                              4
Product Name: HelloWorld




                           5
Workspace Window of Xcode




                                                                                                                       6
Source: http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iPhone101/Articles/01_CreatingProject.html
What Files Are In The Project?

• Source Files


  • AppDelegate.h & AppDelegate.m


  • ViewController.h & ViewController.m


  • ViewController.xib


• Supporting Files


  • HelloWorld-Info.plist


  • main.m
                                          7
iOS Application Life Cycle




 Souce: http://developer.bada.com/article/A-Comparison-between-iOS-and-bada-Application-Development-Part1   8
main() => UIApplicationMain()




• The @autoreleasepool statement supports the Automatic Reference Counting
  (ARC) system. ARC provides automatic object-lifetime management for your
  app.


• The call to UIApplicationMain creates an instance of the
  UIApplication and AppDelegate classes.
                                                                             9
AppDelegate.m




                10
Run and See Result




                     11
IB, XIB, and NIB Files

• Interface Builder (IB) is a GUI builder and object editor.


• Developer creates and configures objects, and then saves them to an archive.


• This archive or container is called “XIB” or “NIB”.


• We can have more than one xib/nib file in the project




                                                               ViewController.xib



                                                                                    12
XIB and NIB Files

• A XIB file is an XML representation of objects and their instance variables,
  and it is compiled into a NIB file when application is built.


• XIB file is easier to work with, but NIB file is smaller and easier to parse.


• NIB file is copied into application bundle (a directory containing the
  executable and any resources)




                                                                                13
Application Bundle on the Simulator

• ~/Library/Application Support/iPhone Simulator/6.0/Applications


• Right Click at HelloWorld.app > Show Package Contents




                         chflags nohidden ~/Library/
                                                                    14
iOS Simulator > Reset Content and Settings...




                                                15
XIB and NIB Files




                    16
ViewController.xib
 • Drag Label onto screen




              1



                            3
                                2


                                    17
ViewController.xib
• Change text to Hello World and click Run
         2



                                             1




                                                 18
HelloWorld (Result)




                      19
HelloWorld2 (Result)

• When a user clicks a button “Say Hello”, “Hello World” is shown on the
  screen.




                                                                           20
ViewController.xib
• Drag Round Rect Button onto screen and delete text of Label




                                                                21
ViewController.h




                   22
ViewController.m




                   23
ViewController.xib
• Link label to Label




                        24
ViewController.xib
• Link sayHello to Button




                            25
Exercise: HelloWorld3

• Add another button to clear the message “Hello World”




                                                          26
Assistant View

• Prior to Xcode 4, outlets and actions needed to be created in the view
  controller’s header file before connecting them in Interface Builder (IB).


• Xcode 4’s assistant view gives us a much faster and more intuitive approach
  that lets us create and connect outlets and actions simultaneously.




                                                                                27
ViewController.xib to ViewController.h
• Control + Drag from an Object in IB to Header File




                                                       28
ViewController.xib
• Can “Say Hello” and “Clear” buttons call to the same action?




                                                                 29
Exercise: HelloWorld4

• Add text field to get the name of user to say “Hello “ user or say “Hello World”
  when there is no name in the text field




                                                                      The same
                                                                      method for
                                                                      two
                                                                      buttons?




                                                                                30
Info Property List File

• Name: <Project Name>-Info.plist


• It contains a list of key-value pairs which is used to specify things such as


   • Icon to display on the home screen


   • Default language of the application




                                                                                  31
HelloWorld-Info.plist




                        32
App Icon and Launch Image for Your Application




                                                 33
Prepare your files


                                                 Launch image
   Display type    App icon size    Icon name                    Image name
                                                     size


   Non-Retina
                     57 x 57        Icon.png      320 x 480      Default.png
    display




  Retina Display    114 x 114      Icon@2x.png    640 x 960     Default@2x.png




                                                                                 34
HelloWorld Summary

• Drag “Icon.png” and “Icon@2x.png”




                                      35
HelloWorld-Info.plist




                        36
HelloWorld Summary

• Drag “Default.png” and “Default@2x.png”




                                            37
How to Change iOS Simulator




                              38
Code Completion
• Type initial character, then Pop-up Windows comes up automatically


  • Keep typing to complete


  • Press TAB to move to next Camel string


  • Press Enter to complete that selection


  • Press Arrow up/down to navigate




                                                                       39
Exercise (Results)




                     40
Exercise: Sample of Data

   • @"Ant"                • @"Insect"
   • @"Bee"                • @"Jelly Fish"
   • @"Cat"                • @"Kingkong"
   • @"Dog"                • @"Leopard"
   • @"Elephant"           • @"Mountain Lion"
   • @"Fish"               • @"Nightingale"
   • @"Goldfish"            • @"Owl"
   • @"Hippo"              • @"Pig"


                                                41
Warning !!

• iOS programming doesn’t have garbage collection (unlike Mac OS
  programming)


• So, we have to keep track of what we need.. what we no longer need.




                                                                        42
Memory Management & String (Before iOS 5)

Scenario: create an NSString object


1. Create a pointer to NSString object


       NSString *str1;


2. Allocate NSString object and set the pointer to object


       str1 = [NSString alloc];

3. Initialize the object that the pointer points to


       str1 = [str1 initWithFormat:@"Hello"];


                                                            43
Memory Management & String (Before iOS 5)



                         1     Retain Count



        str1           Hello     NSString Obj




                                                44
Memory Management & String (Before iOS 5)

• To get current retain count :


     [obj retainCount];
                                          Retain Count
• To increase retain count :


     [obj retain];
                                  Hello     NSString Obj
• To decrease retain count :


     [obj release];




                                                           45
Memory Management & String (Before iOS 5)

 There is another NSString object named str2 which points to a new object
 with message “Ha ha”.

   NSString *str2 = [[NSString alloc] initWithFormat:@"Ha ha"];




 Then reallocate str1 to point to the same object as str2

       str1 = str2;




                                                                            46
Memory Management & String (Before iOS 5)

                                              1     Retain Count


                     This memory
                    space is wasted
                                            Hello      NSString Obj
        str1

        str2
                                      Ha ha       NSString Obj


    Q: What is the retain count for the object with message “Ha ha”?


                                                                       47
Memory Management & String (Before iOS 5)

                                             0     Retain Count


• How can we do the proper set?
                                           Hello


                                  2   Retain Count
       str1

       str2                  Ha ha      NSString Obj

                                                                  48
Memory Management & Array (Before iOS 5)



    1   Retain Count       1   Retain Count




          Obj                    Array




                                              49
Memory Management & Array (Before iOS 5)



    2   Retain Count       1   Retain Count




          Obj                    Array




                                              50
Memory Management & Array (Before iOS 5)

    2   Retain Count


                           1   Retain Count


         Obj1
                                 Array
    1   Retain Count




         Obj2
                                              51
Memory Management & Array (Before iOS 5)

    2   Retain Count


                           1    Retain Count


         Obj1
                                  Array
    2   Retain Count



                       If we release array ?
         Obj2
                                               52
Memory Management & Array (Before iOS 5)

    2   Retain Count


              RELEASE | -1       0    Retain Count


         Obj1
                                        Array
    2   Retain Count

                       RELEASE | -1

         Obj2
                                                     53
Memory Management & Array (Before iOS 5)

    1   Retain Count


                           0   Retain Count


         Obj1
                                 Array
    1   Retain Count




         Obj2
                                              54
Memory Management & Array (Before iOS 5)

In many cases


• You want to have an array.


• You add objects to the array.


• When the array is destroyed, you want the members to be destroyed as well..




                                                                                55
Memory Management & Array (Before iOS 5)



    1   Retain Count       1   Retain Count




          Obj                    Array




                                              56
Memory Management & Array (Before iOS 5)



    2   Retain Count       1   Retain Count




          Obj                    Array

 RELEASE | -1




                                              57
Memory Management & Array (Before iOS 5)



    1   Retain Count       1   Retain Count




          Obj                    Array




                                              58
Memory Management & Array (Before iOS 5)

    1   Retain Count


                           1   Retain Count


         Obj1
                                 Array
    1   Retain Count




         Obj2
                                              59
Memory Management & Array (Before iOS 5)

    1   Retain Count


                             1   Retain Count


         Obj1
                                   Array
    2   Retain Count




         Obj2 RELEASE | -1
                                                60
Memory Management & Array (Before iOS 5)

    1   Retain Count


                           1    Retain Count


         Obj1
                                  Array
    1   Retain Count



                       If we release array ?
         Obj2
                                               61
Memory Management & Array (Before iOS 5)

    0   Retain Count


              RELEASE | -1       0    Retain Count


         Obj1
                                        Array
    0   Retain Count

                       RELEASE | -1

         Obj2
                                                     62
Memory Management & Array (Before iOS 5)

    0   Retain Count


                           0   Retain Count


         Obj1
                                 Array
    0   Retain Count




         Obj2
                                              63
AutoReleasePool

• What method returns object in autorelease pool ?



        NSXyz *a = [NSXyz xyzWith...];


• This is called “Convenience method”.




                                                     64
@property (Before Xcode 4.2)

   @property (attributes) type name;


• The attributes are divided into groups and can take the following values :
   • Access type
       • readwrite (default) : will generate getter and setter
       • readonly : will only generate getter
   • Memory management
      • assign (default) : setter will not retain memory, just assign pointer
      • retain : setter will retain memory
      • copy : setter will copy memory zone (thus calling alloc and thus retain the new copy)
   • Thread management
       • nonatomic : if nonatomic is not mentioned, the setter will be thread-safe by default
       (synchronized method)
                                                                                                65
@synthesize

• @synthesize name;

  • Example: @synthesize str1;

   -(NSString *) str1
   {
       return str1;
   }


   -(void) setStr1:(NSString *) str2
   {
       if (str1 != str2)
       {
           [str2 retain];
           [str1 release];    [ str1 release];
           str1 = str2;         str1 = [str2 copy];   str1 = str2;
       }
   }            retain                  copy            assign


                                                                     66
Some New Features Starting from Xcode 4.2

• Automatic Reference Counting (ARC)


• Default Compiler for iOS development
    • Xcode 4.5 : LLVM 4.1
    • Xcode 4.4 : LLVM 4.0
    • Xcode 4.3 : LLVM 3.1
    • Xcode 4.2 : LLVM (Low Level Virtual Machine) 3.0
    • Xcode 4.1 : LLVM-GCC
    • Xcode 4.0 : GCC (GNU Compiler Collection)



• Storyboarding
	                                                        67
Automatic Reference Counting (ARC)




 Source: http://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html
                                                                                                                                68
ARC

• ARC is a compiler feature that provides automatic memory management of
 Objective-C objects. ARC works by adding code at compile time to ensure
 that objects live as long as necessary, but no longer. Conceptually, it follows
 the same memory management conventions as manual reference counting by
 adding the appropriate memory management calls for you.


• LLVM 3.0 compiler that Apple started shipping with iOS 5 is so smart that it
  will release objects for us, using ARC. That means no more dealloc methods,
  and no more worrying about calling release or autorelease.


• ARC applies to only Objective-C objects, not to Core Foundation objects or
  to memory allocated with malloc.




                                                                                 69
Manual Reference Counting




 Source: http://teamtreehouse.com/library/ios-5-foundations/automatic-reference-counting/getting-started/play
                                                                                                                70
Automatic Reference Counting




                               71
Comparing Manual and Automatic Reference Counting




                                                    72
Strong and Weak properties


• @property (retain) MyClass *myObject;


          => @property (strong) MyClass *myObject;




• @property (assign) MyClass *myObject;


          => @property (weak) MyClass *myObject;




                                                     73
Convert Old Codes to Objective-C ARC Codes

• Open HelloWorld project developed in Xcode 4.0




                                                   74
Changes in HelloWorldAppDelegate.h
           After Converting     Before Converting




                                                    75
Changes in HelloWorldAppDelegate.m
           After Converting    Before Converting




                                                   76
Changes in main.m
           After Converting   Before Converting




                                                  77
Strong property
NSString *firstName = textField.text;




               Source: http://www.raywenderlich.com/5677/beginning-arc-in-ios-5-part-1   78
Weak property
 __weak NSString *weakName = textField.text;




                                               79
Storyboarding

• In Xcode 4.2, the Interface Builder user interface for iOS applications is based
  on the storyboarding of view controllers.


• Storyboarding enables you to use Interface Builder to specify not only all the
  screens in your application, but the transitions between them and the controls
  used to trigger the transitions.


• Thus you can lay out every possible path through your application graphically,
  greatly reducing the amount of code you need to write for a complex
  multiscreen application.




                                                                                     80
New a Single View Application > HelloWorld_Storyboard




                                                   81
MainStoryboard.storyboard




                            82
MainStoryboard.storyboard




                            83
References

• Boonyanit Mathayomchan, Ph.D., “iPhone Application
  Development (BASIC)”, 2011

• Chotipat Pornavalai, iPhone Basic #1, Mini Master of iOS
  Application #1

• Dave Mark, et.al, “Beginning iOS5 Development: Exploring the iOS
  SDK”, 2012

• Joe Conway & Aaron Hillegass, “iPhone Programming: The Big
  Nerd Ranch Guide”, 2010



                                                                     84

More Related Content

Similar to iPhone Programming [2/17] : Introduction to iOS Programming

Adobe AIR Development for the BlackBerry PlayBook
Adobe AIR Development for the BlackBerry PlayBookAdobe AIR Development for the BlackBerry PlayBook
Adobe AIR Development for the BlackBerry PlayBookKyle McInnes
 
iPhone Programming [7/17] : Behind the Scene
iPhone Programming [7/17] : Behind the SceneiPhone Programming [7/17] : Behind the Scene
iPhone Programming [7/17] : Behind the SceneIMC Institute
 
outgoing again
outgoing againoutgoing again
outgoing againspredslide
 
I pad uicatalog_lesson02
I pad uicatalog_lesson02I pad uicatalog_lesson02
I pad uicatalog_lesson02Rich Helton
 
Make Mobile Apps Quickly
Make Mobile Apps QuicklyMake Mobile Apps Quickly
Make Mobile Apps QuicklyGil Irizarry
 
Synapse india reviews on i phone and android os
Synapse india reviews on i phone and android osSynapse india reviews on i phone and android os
Synapse india reviews on i phone and android ossaritasingh19866
 
Building your first iOS app using Xamarin
Building your first iOS app using XamarinBuilding your first iOS app using Xamarin
Building your first iOS app using XamarinGill Cleeren
 
Session 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 applicationSession 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 applicationVu Tran Lam
 
XPages101 - Building an XPages app - Lotusphere 2011
XPages101 - Building an XPages app - Lotusphere 2011XPages101 - Building an XPages app - Lotusphere 2011
XPages101 - Building an XPages app - Lotusphere 2011Tim Clark
 
IBM Domino Designer: Tips and tricks for maximum productivity
IBM Domino Designer: Tips and tricks for maximum productivityIBM Domino Designer: Tips and tricks for maximum productivity
IBM Domino Designer: Tips and tricks for maximum productivitySocialBiz UserGroup
 

Similar to iPhone Programming [2/17] : Introduction to iOS Programming (20)

200910 - iPhone at OOPSLA
200910 - iPhone at OOPSLA200910 - iPhone at OOPSLA
200910 - iPhone at OOPSLA
 
Adobe AIR Development for the BlackBerry PlayBook
Adobe AIR Development for the BlackBerry PlayBookAdobe AIR Development for the BlackBerry PlayBook
Adobe AIR Development for the BlackBerry PlayBook
 
Ios development
Ios developmentIos development
Ios development
 
iPhone Programming [7/17] : Behind the Scene
iPhone Programming [7/17] : Behind the SceneiPhone Programming [7/17] : Behind the Scene
iPhone Programming [7/17] : Behind the Scene
 
outgoing again
outgoing againoutgoing again
outgoing again
 
201010 SPLASH Tutorial
201010 SPLASH Tutorial201010 SPLASH Tutorial
201010 SPLASH Tutorial
 
Citibank
CitibankCitibank
Citibank
 
Project anatomy & hello world
Project anatomy & hello worldProject anatomy & hello world
Project anatomy & hello world
 
I pad uicatalog_lesson02
I pad uicatalog_lesson02I pad uicatalog_lesson02
I pad uicatalog_lesson02
 
Hello world ios v1
Hello world ios v1Hello world ios v1
Hello world ios v1
 
Synapse india mobile apps update
Synapse india mobile apps updateSynapse india mobile apps update
Synapse india mobile apps update
 
Make Mobile Apps Quickly
Make Mobile Apps QuicklyMake Mobile Apps Quickly
Make Mobile Apps Quickly
 
Extending NetBeans IDE
Extending NetBeans IDEExtending NetBeans IDE
Extending NetBeans IDE
 
Synapse india reviews on i phone and android os
Synapse india reviews on i phone and android osSynapse india reviews on i phone and android os
Synapse india reviews on i phone and android os
 
Building your first iOS app using Xamarin
Building your first iOS app using XamarinBuilding your first iOS app using Xamarin
Building your first iOS app using Xamarin
 
Session 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 applicationSession 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 application
 
W1.pptx
W1.pptxW1.pptx
W1.pptx
 
XPages101 - Building an XPages app - Lotusphere 2011
XPages101 - Building an XPages app - Lotusphere 2011XPages101 - Building an XPages app - Lotusphere 2011
XPages101 - Building an XPages app - Lotusphere 2011
 
IBM Domino Designer: Tips and tricks for maximum productivity
IBM Domino Designer: Tips and tricks for maximum productivityIBM Domino Designer: Tips and tricks for maximum productivity
IBM Domino Designer: Tips and tricks for maximum productivity
 
Introduction of Xcode
Introduction of XcodeIntroduction of Xcode
Introduction of Xcode
 

More from IMC Institute

นิตยสาร Digital Trends ฉบับที่ 14
นิตยสาร Digital Trends ฉบับที่ 14นิตยสาร Digital Trends ฉบับที่ 14
นิตยสาร Digital Trends ฉบับที่ 14IMC Institute
 
Digital trends Vol 4 No. 13 Sep-Dec 2019
Digital trends Vol 4 No. 13  Sep-Dec 2019Digital trends Vol 4 No. 13  Sep-Dec 2019
Digital trends Vol 4 No. 13 Sep-Dec 2019IMC Institute
 
บทความ The evolution of AI
บทความ The evolution of AIบทความ The evolution of AI
บทความ The evolution of AIIMC Institute
 
IT Trends eMagazine Vol 4. No.12
IT Trends eMagazine  Vol 4. No.12IT Trends eMagazine  Vol 4. No.12
IT Trends eMagazine Vol 4. No.12IMC Institute
 
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformationเพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital TransformationIMC Institute
 
IT Trends 2019: Putting Digital Transformation to Work
IT Trends 2019: Putting Digital Transformation to WorkIT Trends 2019: Putting Digital Transformation to Work
IT Trends 2019: Putting Digital Transformation to WorkIMC Institute
 
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรมมูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรมIMC Institute
 
IT Trends eMagazine Vol 4. No.11
IT Trends eMagazine  Vol 4. No.11IT Trends eMagazine  Vol 4. No.11
IT Trends eMagazine Vol 4. No.11IMC Institute
 
แนวทางการทำ Digital transformation
แนวทางการทำ Digital transformationแนวทางการทำ Digital transformation
แนวทางการทำ Digital transformationIMC Institute
 
บทความ The New Silicon Valley
บทความ The New Silicon Valleyบทความ The New Silicon Valley
บทความ The New Silicon ValleyIMC Institute
 
นิตยสาร IT Trends ของ IMC Institute ฉบับที่ 10
นิตยสาร IT Trends ของ  IMC Institute  ฉบับที่ 10นิตยสาร IT Trends ของ  IMC Institute  ฉบับที่ 10
นิตยสาร IT Trends ของ IMC Institute ฉบับที่ 10IMC Institute
 
แนวทางการทำ Digital transformation
แนวทางการทำ Digital transformationแนวทางการทำ Digital transformation
แนวทางการทำ Digital transformationIMC Institute
 
The Power of Big Data for a new economy (Sample)
The Power of Big Data for a new economy (Sample)The Power of Big Data for a new economy (Sample)
The Power of Big Data for a new economy (Sample)IMC Institute
 
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง IMC Institute
 
IT Trends eMagazine Vol 3. No.9
IT Trends eMagazine  Vol 3. No.9 IT Trends eMagazine  Vol 3. No.9
IT Trends eMagazine Vol 3. No.9 IMC Institute
 
Thailand software & software market survey 2016
Thailand software & software market survey 2016Thailand software & software market survey 2016
Thailand software & software market survey 2016IMC Institute
 
Developing Business Blockchain Applications on Hyperledger
Developing Business  Blockchain Applications on Hyperledger Developing Business  Blockchain Applications on Hyperledger
Developing Business Blockchain Applications on Hyperledger IMC Institute
 
Digital transformation @thanachart.org
Digital transformation @thanachart.orgDigital transformation @thanachart.org
Digital transformation @thanachart.orgIMC Institute
 
บทความ Big Data จากบล็อก thanachart.org
บทความ Big Data จากบล็อก thanachart.orgบทความ Big Data จากบล็อก thanachart.org
บทความ Big Data จากบล็อก thanachart.orgIMC Institute
 
กลยุทธ์ 5 ด้านกับการทำ Digital Transformation
กลยุทธ์ 5 ด้านกับการทำ Digital Transformationกลยุทธ์ 5 ด้านกับการทำ Digital Transformation
กลยุทธ์ 5 ด้านกับการทำ Digital TransformationIMC Institute
 

More from IMC Institute (20)

นิตยสาร Digital Trends ฉบับที่ 14
นิตยสาร Digital Trends ฉบับที่ 14นิตยสาร Digital Trends ฉบับที่ 14
นิตยสาร Digital Trends ฉบับที่ 14
 
Digital trends Vol 4 No. 13 Sep-Dec 2019
Digital trends Vol 4 No. 13  Sep-Dec 2019Digital trends Vol 4 No. 13  Sep-Dec 2019
Digital trends Vol 4 No. 13 Sep-Dec 2019
 
บทความ The evolution of AI
บทความ The evolution of AIบทความ The evolution of AI
บทความ The evolution of AI
 
IT Trends eMagazine Vol 4. No.12
IT Trends eMagazine  Vol 4. No.12IT Trends eMagazine  Vol 4. No.12
IT Trends eMagazine Vol 4. No.12
 
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformationเพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
เพราะเหตุใด Digitization ไม่ตอบโจทย์ Digital Transformation
 
IT Trends 2019: Putting Digital Transformation to Work
IT Trends 2019: Putting Digital Transformation to WorkIT Trends 2019: Putting Digital Transformation to Work
IT Trends 2019: Putting Digital Transformation to Work
 
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรมมูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
มูลค่าตลาดดิจิทัลไทย 3 อุตสาหกรรม
 
IT Trends eMagazine Vol 4. No.11
IT Trends eMagazine  Vol 4. No.11IT Trends eMagazine  Vol 4. No.11
IT Trends eMagazine Vol 4. No.11
 
แนวทางการทำ Digital transformation
แนวทางการทำ Digital transformationแนวทางการทำ Digital transformation
แนวทางการทำ Digital transformation
 
บทความ The New Silicon Valley
บทความ The New Silicon Valleyบทความ The New Silicon Valley
บทความ The New Silicon Valley
 
นิตยสาร IT Trends ของ IMC Institute ฉบับที่ 10
นิตยสาร IT Trends ของ  IMC Institute  ฉบับที่ 10นิตยสาร IT Trends ของ  IMC Institute  ฉบับที่ 10
นิตยสาร IT Trends ของ IMC Institute ฉบับที่ 10
 
แนวทางการทำ Digital transformation
แนวทางการทำ Digital transformationแนวทางการทำ Digital transformation
แนวทางการทำ Digital transformation
 
The Power of Big Data for a new economy (Sample)
The Power of Big Data for a new economy (Sample)The Power of Big Data for a new economy (Sample)
The Power of Big Data for a new economy (Sample)
 
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
บทความ Robotics แนวโน้มใหม่สู่บริการเฉพาะทาง
 
IT Trends eMagazine Vol 3. No.9
IT Trends eMagazine  Vol 3. No.9 IT Trends eMagazine  Vol 3. No.9
IT Trends eMagazine Vol 3. No.9
 
Thailand software & software market survey 2016
Thailand software & software market survey 2016Thailand software & software market survey 2016
Thailand software & software market survey 2016
 
Developing Business Blockchain Applications on Hyperledger
Developing Business  Blockchain Applications on Hyperledger Developing Business  Blockchain Applications on Hyperledger
Developing Business Blockchain Applications on Hyperledger
 
Digital transformation @thanachart.org
Digital transformation @thanachart.orgDigital transformation @thanachart.org
Digital transformation @thanachart.org
 
บทความ Big Data จากบล็อก thanachart.org
บทความ Big Data จากบล็อก thanachart.orgบทความ Big Data จากบล็อก thanachart.org
บทความ Big Data จากบล็อก thanachart.org
 
กลยุทธ์ 5 ด้านกับการทำ Digital Transformation
กลยุทธ์ 5 ด้านกับการทำ Digital Transformationกลยุทธ์ 5 ด้านกับการทำ Digital Transformation
กลยุทธ์ 5 ด้านกับการทำ Digital Transformation
 

Recently uploaded

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

Recently uploaded (20)

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

iPhone Programming [2/17] : Introduction to iOS Programming

  • 1. Introduction to iOS Programming Dr. Thanisa Kruawaisayawan www.imcinstitute.com
  • 2. Get Started • What are needed? • Tools: • Computer with Mac OSX (Intel based and Mountain Lion) • Xcode 4.5.2 • iOS Developer Program (optional) • Knowledge and Creativity • Time 2
  • 3. iOS Developer Programs • iOS Developer Program ($99/year) • To distribute apps on the App Store as an individual, sole proprietor, company or organization (up to 100 registered devices) • iOS Developer Enterprise Program ($299/year) • To develop proprietary apps for internal distribution within your company, organization, government entity or educational institution • iOS Developer University Program (Free) • To introduce iOS development into curriculum (up to 200 students) 3
  • 4. iOS > Application > Single View Application 4
  • 6. Workspace Window of Xcode 6 Source: http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iPhone101/Articles/01_CreatingProject.html
  • 7. What Files Are In The Project? • Source Files • AppDelegate.h & AppDelegate.m • ViewController.h & ViewController.m • ViewController.xib • Supporting Files • HelloWorld-Info.plist • main.m 7
  • 8. iOS Application Life Cycle Souce: http://developer.bada.com/article/A-Comparison-between-iOS-and-bada-Application-Development-Part1 8
  • 9. main() => UIApplicationMain() • The @autoreleasepool statement supports the Automatic Reference Counting (ARC) system. ARC provides automatic object-lifetime management for your app. • The call to UIApplicationMain creates an instance of the UIApplication and AppDelegate classes. 9
  • 11. Run and See Result 11
  • 12. IB, XIB, and NIB Files • Interface Builder (IB) is a GUI builder and object editor. • Developer creates and configures objects, and then saves them to an archive. • This archive or container is called “XIB” or “NIB”. • We can have more than one xib/nib file in the project ViewController.xib 12
  • 13. XIB and NIB Files • A XIB file is an XML representation of objects and their instance variables, and it is compiled into a NIB file when application is built. • XIB file is easier to work with, but NIB file is smaller and easier to parse. • NIB file is copied into application bundle (a directory containing the executable and any resources) 13
  • 14. Application Bundle on the Simulator • ~/Library/Application Support/iPhone Simulator/6.0/Applications • Right Click at HelloWorld.app > Show Package Contents chflags nohidden ~/Library/ 14
  • 15. iOS Simulator > Reset Content and Settings... 15
  • 16. XIB and NIB Files 16
  • 17. ViewController.xib • Drag Label onto screen 1 3 2 17
  • 18. ViewController.xib • Change text to Hello World and click Run 2 1 18
  • 20. HelloWorld2 (Result) • When a user clicks a button “Say Hello”, “Hello World” is shown on the screen. 20
  • 21. ViewController.xib • Drag Round Rect Button onto screen and delete text of Label 21
  • 26. Exercise: HelloWorld3 • Add another button to clear the message “Hello World” 26
  • 27. Assistant View • Prior to Xcode 4, outlets and actions needed to be created in the view controller’s header file before connecting them in Interface Builder (IB). • Xcode 4’s assistant view gives us a much faster and more intuitive approach that lets us create and connect outlets and actions simultaneously. 27
  • 28. ViewController.xib to ViewController.h • Control + Drag from an Object in IB to Header File 28
  • 29. ViewController.xib • Can “Say Hello” and “Clear” buttons call to the same action? 29
  • 30. Exercise: HelloWorld4 • Add text field to get the name of user to say “Hello “ user or say “Hello World” when there is no name in the text field The same method for two buttons? 30
  • 31. Info Property List File • Name: <Project Name>-Info.plist • It contains a list of key-value pairs which is used to specify things such as • Icon to display on the home screen • Default language of the application 31
  • 33. App Icon and Launch Image for Your Application 33
  • 34. Prepare your files Launch image Display type App icon size Icon name Image name size Non-Retina 57 x 57 Icon.png 320 x 480 Default.png display Retina Display 114 x 114 Icon@2x.png 640 x 960 Default@2x.png 34
  • 35. HelloWorld Summary • Drag “Icon.png” and “Icon@2x.png” 35
  • 37. HelloWorld Summary • Drag “Default.png” and “Default@2x.png” 37
  • 38. How to Change iOS Simulator 38
  • 39. Code Completion • Type initial character, then Pop-up Windows comes up automatically • Keep typing to complete • Press TAB to move to next Camel string • Press Enter to complete that selection • Press Arrow up/down to navigate 39
  • 41. Exercise: Sample of Data • @"Ant" • @"Insect" • @"Bee" • @"Jelly Fish" • @"Cat" • @"Kingkong" • @"Dog" • @"Leopard" • @"Elephant" • @"Mountain Lion" • @"Fish" • @"Nightingale" • @"Goldfish" • @"Owl" • @"Hippo" • @"Pig" 41
  • 42. Warning !! • iOS programming doesn’t have garbage collection (unlike Mac OS programming) • So, we have to keep track of what we need.. what we no longer need. 42
  • 43. Memory Management & String (Before iOS 5) Scenario: create an NSString object 1. Create a pointer to NSString object NSString *str1; 2. Allocate NSString object and set the pointer to object str1 = [NSString alloc]; 3. Initialize the object that the pointer points to str1 = [str1 initWithFormat:@"Hello"]; 43
  • 44. Memory Management & String (Before iOS 5) 1 Retain Count str1 Hello NSString Obj 44
  • 45. Memory Management & String (Before iOS 5) • To get current retain count : [obj retainCount]; Retain Count • To increase retain count : [obj retain]; Hello NSString Obj • To decrease retain count : [obj release]; 45
  • 46. Memory Management & String (Before iOS 5) There is another NSString object named str2 which points to a new object with message “Ha ha”. NSString *str2 = [[NSString alloc] initWithFormat:@"Ha ha"]; Then reallocate str1 to point to the same object as str2 str1 = str2; 46
  • 47. Memory Management & String (Before iOS 5) 1 Retain Count This memory space is wasted Hello NSString Obj str1 str2 Ha ha NSString Obj Q: What is the retain count for the object with message “Ha ha”? 47
  • 48. Memory Management & String (Before iOS 5) 0 Retain Count • How can we do the proper set? Hello 2 Retain Count str1 str2 Ha ha NSString Obj 48
  • 49. Memory Management & Array (Before iOS 5) 1 Retain Count 1 Retain Count Obj Array 49
  • 50. Memory Management & Array (Before iOS 5) 2 Retain Count 1 Retain Count Obj Array 50
  • 51. Memory Management & Array (Before iOS 5) 2 Retain Count 1 Retain Count Obj1 Array 1 Retain Count Obj2 51
  • 52. Memory Management & Array (Before iOS 5) 2 Retain Count 1 Retain Count Obj1 Array 2 Retain Count If we release array ? Obj2 52
  • 53. Memory Management & Array (Before iOS 5) 2 Retain Count RELEASE | -1 0 Retain Count Obj1 Array 2 Retain Count RELEASE | -1 Obj2 53
  • 54. Memory Management & Array (Before iOS 5) 1 Retain Count 0 Retain Count Obj1 Array 1 Retain Count Obj2 54
  • 55. Memory Management & Array (Before iOS 5) In many cases • You want to have an array. • You add objects to the array. • When the array is destroyed, you want the members to be destroyed as well.. 55
  • 56. Memory Management & Array (Before iOS 5) 1 Retain Count 1 Retain Count Obj Array 56
  • 57. Memory Management & Array (Before iOS 5) 2 Retain Count 1 Retain Count Obj Array RELEASE | -1 57
  • 58. Memory Management & Array (Before iOS 5) 1 Retain Count 1 Retain Count Obj Array 58
  • 59. Memory Management & Array (Before iOS 5) 1 Retain Count 1 Retain Count Obj1 Array 1 Retain Count Obj2 59
  • 60. Memory Management & Array (Before iOS 5) 1 Retain Count 1 Retain Count Obj1 Array 2 Retain Count Obj2 RELEASE | -1 60
  • 61. Memory Management & Array (Before iOS 5) 1 Retain Count 1 Retain Count Obj1 Array 1 Retain Count If we release array ? Obj2 61
  • 62. Memory Management & Array (Before iOS 5) 0 Retain Count RELEASE | -1 0 Retain Count Obj1 Array 0 Retain Count RELEASE | -1 Obj2 62
  • 63. Memory Management & Array (Before iOS 5) 0 Retain Count 0 Retain Count Obj1 Array 0 Retain Count Obj2 63
  • 64. AutoReleasePool • What method returns object in autorelease pool ? NSXyz *a = [NSXyz xyzWith...]; • This is called “Convenience method”. 64
  • 65. @property (Before Xcode 4.2) @property (attributes) type name; • The attributes are divided into groups and can take the following values : • Access type • readwrite (default) : will generate getter and setter • readonly : will only generate getter • Memory management • assign (default) : setter will not retain memory, just assign pointer • retain : setter will retain memory • copy : setter will copy memory zone (thus calling alloc and thus retain the new copy) • Thread management • nonatomic : if nonatomic is not mentioned, the setter will be thread-safe by default (synchronized method) 65
  • 66. @synthesize • @synthesize name; • Example: @synthesize str1; -(NSString *) str1 { return str1; } -(void) setStr1:(NSString *) str2 { if (str1 != str2) { [str2 retain]; [str1 release]; [ str1 release]; str1 = str2; str1 = [str2 copy]; str1 = str2; } } retain copy assign 66
  • 67. Some New Features Starting from Xcode 4.2 • Automatic Reference Counting (ARC) • Default Compiler for iOS development • Xcode 4.5 : LLVM 4.1 • Xcode 4.4 : LLVM 4.0 • Xcode 4.3 : LLVM 3.1 • Xcode 4.2 : LLVM (Low Level Virtual Machine) 3.0 • Xcode 4.1 : LLVM-GCC • Xcode 4.0 : GCC (GNU Compiler Collection) • Storyboarding 67
  • 68. Automatic Reference Counting (ARC) Source: http://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html 68
  • 69. ARC • ARC is a compiler feature that provides automatic memory management of Objective-C objects. ARC works by adding code at compile time to ensure that objects live as long as necessary, but no longer. Conceptually, it follows the same memory management conventions as manual reference counting by adding the appropriate memory management calls for you. • LLVM 3.0 compiler that Apple started shipping with iOS 5 is so smart that it will release objects for us, using ARC. That means no more dealloc methods, and no more worrying about calling release or autorelease. • ARC applies to only Objective-C objects, not to Core Foundation objects or to memory allocated with malloc. 69
  • 70. Manual Reference Counting Source: http://teamtreehouse.com/library/ios-5-foundations/automatic-reference-counting/getting-started/play 70
  • 72. Comparing Manual and Automatic Reference Counting 72
  • 73. Strong and Weak properties • @property (retain) MyClass *myObject; => @property (strong) MyClass *myObject; • @property (assign) MyClass *myObject; => @property (weak) MyClass *myObject; 73
  • 74. Convert Old Codes to Objective-C ARC Codes • Open HelloWorld project developed in Xcode 4.0 74
  • 75. Changes in HelloWorldAppDelegate.h After Converting Before Converting 75
  • 76. Changes in HelloWorldAppDelegate.m After Converting Before Converting 76
  • 77. Changes in main.m After Converting Before Converting 77
  • 78. Strong property NSString *firstName = textField.text; Source: http://www.raywenderlich.com/5677/beginning-arc-in-ios-5-part-1 78
  • 79. Weak property __weak NSString *weakName = textField.text; 79
  • 80. Storyboarding • In Xcode 4.2, the Interface Builder user interface for iOS applications is based on the storyboarding of view controllers. • Storyboarding enables you to use Interface Builder to specify not only all the screens in your application, but the transitions between them and the controls used to trigger the transitions. • Thus you can lay out every possible path through your application graphically, greatly reducing the amount of code you need to write for a complex multiscreen application. 80
  • 81. New a Single View Application > HelloWorld_Storyboard 81
  • 84. References • Boonyanit Mathayomchan, Ph.D., “iPhone Application Development (BASIC)”, 2011 • Chotipat Pornavalai, iPhone Basic #1, Mini Master of iOS Application #1 • Dave Mark, et.al, “Beginning iOS5 Development: Exploring the iOS SDK”, 2012 • Joe Conway & Aaron Hillegass, “iPhone Programming: The Big Nerd Ranch Guide”, 2010 84