SlideShare uma empresa Scribd logo
1 de 32
iOS – Development Overview
iOS Overview



    Cocoa Touch       Core OS

       Media

    Core Services   OS X Kernel   Power management

                    Mach 3.0      Keychain Access
      Core OS       BSD           Certificates

                    Sockets       File System

                    Security      Bonjour




2
iOS Overview



    Cocoa Touch     Core Services

       Media

    Core Services   Collections     Core Location

                    Address Book    Net Services
      Core OS       Networking      Threading

                    File Access     Preferences

                    SQLite          URL Utilities




3
iOS Overview



    Cocoa Touch         Media

       Media

    Core Services   Core Audio        JPEG, PNG, TIFF

                    OpenAL            PDF
      Core OS       Audio Mixing      Quartz (2D)

                    Audio Recording   Core Animation

                    Video Playback    OpenGL




4
iOS Overview



    Cocoa Touch     Cocoa Touch

       Media
                    Multi-touch      Alerts
    Core Services
                    Core Motion      Web View

      Core OS       View Hierarchy   Map Kit

                    Localization     Image Picker

                    Controls         Camera




5
Platform Components
• Tools



• Language            [display setTextColor:[UIColor blackColor]];



• Frameworks




• Design Strategies           V



6
Model View Controller

                               Controller




                  Model                        View




    Model – What your application is (but not how it is displayed)
    Controller– How your model is presented to User (UI Logic)
    View – Controller’s Minions



7
iOS Application Structure
                            App Code



                              Boilerplate code


                                       Resources Images,
                                       Videos, Sound, IB,
                                             Data


                                       Linked Frameworks,
                                           Foundation,
                                         Graphics, Sound


                                  The Executables


                            Targets (Various
                             Build Settings)


8
Application Life Cycle
    int main(int argc, char *argv[]) {
                  NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
                  int retVal = UIApplicationMain(argc, argv, nil, nil);
                  [pool release];
                  return retVal;
    }




9
Objective C
                            CalculatorViewController



                                Controller
                                                            action



                                                                x
                                                        7
              Model                                         View
                                                        4
                                                               +

                                                                         operationPressed:
          CalculatorModel                                   UI Buttons



                                        digitPressed:




10
Model
                                                                      Header file
                               CalculatorModel.h
       Model
                                    Name of the class


              #import <Foundation/Foundation.h>
                                                                   Class’s Superclass
              @interface CalculatorModel : NSObject
              {
                                                                      Instance Variable between the
                  double operand;                                              paranthesis
              }
Return Type
              -(void) setOperand : (double) anOperand;

              -(double) performOperation : (NSString*)operation;
                                                                                    Method declarations


                        Name of the method          Method argument
              @end




 11
Model
                                                          Implementation File.
                         CalculatorModel.m
     Model


       #import CalculatorModel.h

       @implementation CalculatorModel

       -(void) setOperand:(double) anOperand
       {
          operand = anOperand;
       }

       -(double) performOperation: (NSString*)operation
       {
           [ operation sendMessage:argument ];
           return aDouble;

       }

       @end




12
Controller                                                    View




     Controller                                                      7   8   9   *


                                                                     4   5   6   /
     #import <UIKit/UIKit.h>

     @interface CalculatorViewController : UIViewController          1   2   3   +
     {
                                           Model                     C   0   =   -
         CalculatorModel *model;

         IBOutlet UILabel *display;         View

     }

     -( IBAction ) digitPressed : ( UIButton *) sender;


     - (IBAction ) operationPressed : (UIButton *) sender;




13
7   8   9   *


                  4   5   6   /


                  1   2   3   +


                  C   0   =   -
     Controller




14
7   8   9   *
     Events
     • digitPressed:
     - operationPressed:
                           4   5   6   /


                           1   2   3   +


                           C   0   =   -




15
Objective C - Methods
- (NSArray *)shipsAtPoint:(CGPoint)bombLocation withDamage:(BOOL)damaged;




            Instance Methods                                                Class Methods

 • Start with a dash ( - )                                     • Starts with a plus ( + ), used for
 • Normal method                                               singletons, allocation, utilities.
 • Can access instance variables inside as if                         +(id) alloc;
 they were locals                                              • Can not access instance variable inside.
 • can send message to self and super                          • Message to “Self” and “Super” mean
 inside                                                        something a little different. Both invoke
 • Example                                                     only other “class” methods. Inheritance
       BOOL destroyed = [ ship                                 does not work.
       dropBomb:bombType at:dropPoint                          • Example
       from:height];                                                  CalculatorModel *model = [[
                                                                      CalculatorModel alloc] init];




16
Objective C – Instance Variables

     Scope
     By default, instance variables are @protected (only the class and subclass can access).
     Can be marked @private (only the class can access) or @public (anyone can access)

     Scope Syntax
     @interface MyObject: NSObject
     {
                 int foo;
       @private
                 int eye;
                 int jet;
       @protected
                 int bar;
       @public
                 int forum;
                 int xyz;
     }




17
Obj C - Properties
     • Now forget everything on the previous slide
           •Mark all instance variable @private
           • Use @property and dot to access instance variables
     • Create methods to get/set an instance variable value

      @interface MyObject : NSObject
      {
         @private
           int eye;
       }                                      Letter after “set” MUST be capitalized,
                                              otherwise dot notation will not work
      - (int) eye;
      - (void) setEye : (int) anInt;
      @end




18
Obj C - Properties
     • @property
         Complier can generate get/set methods declaration with @property directive.

     @interface MyObject : NSObject
     {
       @private
         int eye;
     }
     @property int eye;
      - (int) eye;                         hidden
     - (void) setEye : (int) anInt;
     @end



                                      If “readonly” keyword is used only get method will
     @property (readonly) int eye;                      be generated.




19
Obj C - Properties
 Implementation (.m) file

 @implementation MyObject
   -(int) eye{
    return eye;
   }
 -(void) setEye:(int)anInt{
  eye = anInt;
   }

     Compiler can generate set/get methods by using keyword @synthesize
     @implementation MyObject
     @synthesize eye;
     - (int)eye {
                   return eye;
     }
     - (void)setEye:(int)anInt {
                   eye = anInt;
     }
     @end




20
Obj C – Dynamic Binding
     • All objects are allocated to heap, so use pointers
     • It’s legal to “cast” a pointer.
     • All objects inherited from NSObjects knows about
           • isKindOfClass
           • isMemberOfClass
           • respondToSelector




21
Frameworks
 Foundation Framework
 • NSObject
      • Base class for pretty much every object in the iOS SDK.
      • Implements memory management primitives
 • NSString
      • Unicode
      • Used throughout iOS instead of C language char *
      • An NSString instance can not be modified. They are immutable
 • NSMutableString
      • Mutable version of NSString.
 • NSNumber, NSData, NSDate
 • NSArray, NSMutableArray
 • NSDictionary, NSMutableDictionary
 • NSSet, NSMutableSet
 • NSUserDefaults




22
Creating Objects
     Two Step process
         -allocate
         -Initiate

     alloc makes space in heap for class’s instance variables.
     Each class has a designated “initializer” method.

     MyObject *obj = [ [ MyObject alloc] init];




23
Getting Objects
     alloc/init is not the only way to “get” an object. Plenty of classes give the object if you ask
     for it.

     NSString *newDisplay = [ display.text stringByAppendingString:digit ];
     NSArray *keys = [ dictionary allKeys];

     Who frees the memory for all these objects?

     No Garbage collection in iOS

     Answer lies in “reference counting”




24
Reference Counting
     -Take the ownership for an object you want to keep a pointer to
     - When you are done with the object, you give up the ownership
     - When no one claims ownership for an object, it gets de allocated.


     So when do we take the ownership?
     Own any object as soon as we send a msg with new, alloc, or copy. But if we receive the object from any other
     source you don’t own it, but we can take ownership by sending it the NSObject message “retain”.

     The object which we receive from any other source, we’ll own it temporarily until the call stack unwinds Or, the
     object is retained.

     Once we are done with the object, send the object the NSObject message “release”.
                                                                        We now own theMoney, we got it using
                                                                       the method alloc. We are responsible for
     -(Money *) showMeTheMoney:(double) amount {                                 sending it release
         Money *theMoney = [[ Money alloc] init:amount];
         [theMoney autorelease];                                  We’ve now released the object but it won’t happen
         return Money;                                          until the caller of this method has had chance to retain
                                                                                 to theMoney if they want.
     }

     Caller
     Money *myMoney = [ bank showMeTheMoney:5000];
     [myMoney retain];

25
Deallocation

 What happens when the last owner calls release?
  A special method, dealloc, is called on the object & the object’s memory is returned to the heap. After this
 happens, sending a message to the object will crash the program.

 Override “dealloc” in your class but NEVER call it !!! [ Strange ? ]
  It only gets called by release when the last owner has ‘released’ the object. The one exception about calling it is
 that you should call [super dealloc] in your dealloc.


 Example
     - (void) dealloc
 {
       [brain release];
       [super dealloc];
 }




26
@property
     Example
     display.text = [display.text stringByAppendingString:digit];



 This is still owned by display (the UILabel). We don’t             This is the NSString we acquired. It comes back
 retain it because we are not going to keep it. We’re               autoreleased. We’re not going to retain this one either
 just going to use it to acquire a different NSString               b’cause we’re just going to pass it on to display’s text
 from stringByAppendingString                                       property setter method.


     Setting an instance variable via setter method (via property)
      Did we retain that object? We need to retain instance variable and this can be done via setter methods but what about
     @synthesis

     There are 3 options for setters made by @synthesis
     @property (retain) NSArray *myArrayProperty;
     @property (copy) NSString *someNameProperty;
     @property (assign) id delegate;

     The first 2 options are straight forward. The third option means that neither retain nor copy is sent to the object passed to
     the setter. This means that if this object is released by all other owners, we’ll have a bad pointer. So we only use “assign” if
     the passed object essentially owns the object with the property.

     A controller and its views (b’cause a View should never outlive its controller) A View can have a property (delegate is very
     common) which is assigned to its controller.


27
@property examples
     @property (retain) NSString *name;

     @synthesis will create a setter equivalent to

     -(void) setName:(NSString *) aString
                                                    @synthesis will release the                     retain
                                                previous object (if any, could be
     {                                         nil) before setting and retaining the
       [name release];                                       new one.
       name = [aString retain];
     }

                                                                  @property (copy) NSString *name;

                                                                  @synthesis will create a setter equivalent to
                                 copy                             -(void) setName:(NSString *) aString
                                                                  {
                                                                    [name release];
                                                                    name = [aString copy];
                                                                  }

@property (assign) NSString *name;

@synthesis will create a setter equivalent to
                                                                                                   assign
-(void) setName:(NSString *) aString
{
  name = aString;
}


28
#import <Foundation/Foundation.h>    @protocol ProcessDataDelegate <NSObject> @required - (void) processSuccessful: (BOOL)success; @end




      protocols
        Protocols can be useful in a number of cases, a common usage is to define method that are to be implemented by other
        classes.


        Similar to @interface, but no implementation
        @protocol Foo
         -(void) doSomething; // implementors must implement
        @optional
          -(int) getSomething; // Optional to implement.

        Class that implement will look like
        @interfaceMyClass : NSObject <Foo>

        …

        @end

        Use of protocols are mainly in delegates and dataSources

        The delegate or dataSource is always defined as an assign @property

        @property (assign) id <UISomeObjectDelegate> delegate;




      29
Protocols
#import <Foundation/Foundation.h>           #import "ClassWithProtocol.h"

@protocol ProcessDataDelegate <NSObject>    @implementation ClassWithProtocol

-(void) processSuccessful: (BOOL)success;   @synthesize delegate;

@end                                        -(void)processComplete
                                            {
                                              [[self delegate] processSuccessful:YES];
@interface ClassWithProtocol : NSObject {
                                            }
     id <ProcessDataDelegate> delegate;     -(void)startSomeProcess
                                            {
}                                              [NSTimer scheduledTimerWithTimeInterval:5.0 target:self
                                            selector:@selector(processComplete) userInfo:nil repeats:YES];
@property (retain) id delegate;             }

-(void)startSomeProcess;

@end




    30
Application Delegate
    Class that adopts the protocol.




HappinessAppDelegate.h (header file for Application Delegate)                     This       object     implements        the
                                                                                  UIApplicationDelegate    protocol.     The
                                                                                  applicationDidxxx and    applicationWillxxx
@interface HappinessAppDelegate : NSObject <UIApplicationDelegate>                methods
{
  UIWindow *window;
                                                                                           Instance       Variable/property/outlet
     HappynessViewController *viewController;                                              pointing to HappynessViewController
}                                                                                          (our controller) also hooked up to
                                                                                           MainWindow.xib
@property (nonatomic, retain) IBOutlet UIWindow *window;

@property (nonatomic, retain) IBOutlet HappynessViewController *viewController;

@end

     Instance Variable/property/outlet pointing to the top-level view for this
     application (UIWindow). This is hooked up to MainWindow.xib




31
Adopting Protocol & Delegate
#import <UIKit/UIKit.h>                           #import "TestAppDelegate.h"
                                                  #import "ClassWithProtocol.h"
#import "ClassWithProtocol.h"
                                                  @implementation TestAppDelegate
@interface TestAppDelegate : NSObject
   <UIApplicationDelegate, ProcessDataDelegate>   @synthesize window;
                                                  UITableViewDelegate
{
                                                  -(void)processSuccessful:(BOOL)success;
                                                  {
            UIWindow *window;
                                                  NSLog(@"Process completed");
       ClassWithProtocol *protocolTest;
                                                  }

}                                                 -(void)applicationDidFinishLaunching:(UIApplication
                                                  *)application
@property (nonatomic, retain) UIWindow *window;   {
                                                   // Create and initialize the window
@end                                                 window = [[UIWindow alloc] initWithFrame:[[UIScreen
                                                  mainScreen] bounds]];

                                                      protocolTest = [[ClassWithProtocol alloc] init];
                                                  [protocolTest setDelegate:self];
                                                  [protocolTest startSomeProcess];

                                                  [window makeKeyAndVisible];
                                                  }

                                                  -(void)dealloc {
                                                  [window release];
                                                  [super dealloc];
                                                  }
       32
                                                  @end

Mais conteúdo relacionado

Mais procurados

Implementing Data Visualization Apps on iOS Devices
Implementing Data Visualization Apps on iOS DevicesImplementing Data Visualization Apps on iOS Devices
Implementing Data Visualization Apps on iOS DevicesDouglass Turner
 
What's New In Python 2.6
What's New In Python 2.6What's New In Python 2.6
What's New In Python 2.6Richard Jones
 
Graphiti and GMF Compared
Graphiti and GMF ComparedGraphiti and GMF Compared
Graphiti and GMF Comparedkoentsje
 
안드로이드 데이터 바인딩
안드로이드 데이터 바인딩안드로이드 데이터 바인딩
안드로이드 데이터 바인딩GDG Korea
 
L0020 - The Basic RCP Application
L0020 - The Basic RCP ApplicationL0020 - The Basic RCP Application
L0020 - The Basic RCP ApplicationTonny Madsen
 
Surface flingerservice(서피스플링거서비스초기화)
Surface flingerservice(서피스플링거서비스초기화)Surface flingerservice(서피스플링거서비스초기화)
Surface flingerservice(서피스플링거서비스초기화)fefe7270
 
Building High Perf Web Apps - IE8 Firestarter
Building High Perf Web Apps - IE8 FirestarterBuilding High Perf Web Apps - IE8 Firestarter
Building High Perf Web Apps - IE8 FirestarterMithun T. Dhar
 
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...Eelco Visser
 
Criando jogos para o windows 8
Criando jogos para o windows 8Criando jogos para o windows 8
Criando jogos para o windows 8José Farias
 
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)lennartkats
 
CodeMash - Building Rich Apps with Groovy SwingBuilder
CodeMash - Building Rich Apps with Groovy SwingBuilderCodeMash - Building Rich Apps with Groovy SwingBuilder
CodeMash - Building Rich Apps with Groovy SwingBuilderAndres Almiray
 
Oop05 6
Oop05 6Oop05 6
Oop05 6schwaa
 
Php Development With Eclipde PDT
Php Development With Eclipde PDTPhp Development With Eclipde PDT
Php Development With Eclipde PDTBastian Feder
 
Hibernate
Hibernate Hibernate
Hibernate Sunil OS
 
JavaFX and Scala in the Cloud
JavaFX and Scala in the CloudJavaFX and Scala in the Cloud
JavaFX and Scala in the CloudStephen Chin
 

Mais procurados (20)

Implementing Data Visualization Apps on iOS Devices
Implementing Data Visualization Apps on iOS DevicesImplementing Data Visualization Apps on iOS Devices
Implementing Data Visualization Apps on iOS Devices
 
Unit 5
Unit 5Unit 5
Unit 5
 
What's New In Python 2.6
What's New In Python 2.6What's New In Python 2.6
What's New In Python 2.6
 
Graphiti and GMF Compared
Graphiti and GMF ComparedGraphiti and GMF Compared
Graphiti and GMF Compared
 
Creating Alloy Widgets
Creating Alloy WidgetsCreating Alloy Widgets
Creating Alloy Widgets
 
안드로이드 데이터 바인딩
안드로이드 데이터 바인딩안드로이드 데이터 바인딩
안드로이드 데이터 바인딩
 
Graphiti presentation
Graphiti presentationGraphiti presentation
Graphiti presentation
 
L0020 - The Basic RCP Application
L0020 - The Basic RCP ApplicationL0020 - The Basic RCP Application
L0020 - The Basic RCP Application
 
Surface flingerservice(서피스플링거서비스초기화)
Surface flingerservice(서피스플링거서비스초기화)Surface flingerservice(서피스플링거서비스초기화)
Surface flingerservice(서피스플링거서비스초기화)
 
Building High Perf Web Apps - IE8 Firestarter
Building High Perf Web Apps - IE8 FirestarterBuilding High Perf Web Apps - IE8 Firestarter
Building High Perf Web Apps - IE8 Firestarter
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...
 
Criando jogos para o windows 8
Criando jogos para o windows 8Criando jogos para o windows 8
Criando jogos para o windows 8
 
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
 
CodeMash - Building Rich Apps with Groovy SwingBuilder
CodeMash - Building Rich Apps with Groovy SwingBuilderCodeMash - Building Rich Apps with Groovy SwingBuilder
CodeMash - Building Rich Apps with Groovy SwingBuilder
 
Oop05 6
Oop05 6Oop05 6
Oop05 6
 
Php Development With Eclipde PDT
Php Development With Eclipde PDTPhp Development With Eclipde PDT
Php Development With Eclipde PDT
 
Hibernate
Hibernate Hibernate
Hibernate
 
L0033 - JFace
L0033 - JFaceL0033 - JFace
L0033 - JFace
 
JavaFX and Scala in the Cloud
JavaFX and Scala in the CloudJavaFX and Scala in the Cloud
JavaFX and Scala in the Cloud
 

Semelhante a iOS Development Overview: Core Components and Frameworks

Code camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una DalyCode camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una DalyUna Daly
 
iPhone Development Intro
iPhone Development IntroiPhone Development Intro
iPhone Development IntroLuis Azevedo
 
Pentesting iOS Apps - Runtime Analysis and Manipulation
Pentesting iOS Apps - Runtime Analysis and ManipulationPentesting iOS Apps - Runtime Analysis and Manipulation
Pentesting iOS Apps - Runtime Analysis and ManipulationAndreas Kurtz
 
iOS,From Development to Distribution
iOS,From Development to DistributioniOS,From Development to Distribution
iOS,From Development to DistributionTunvir Rahman Tusher
 
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...Maarten Balliauw
 
iOS 101 - Xcode, Objective-C, iOS APIs
iOS 101 - Xcode, Objective-C, iOS APIsiOS 101 - Xcode, Objective-C, iOS APIs
iOS 101 - Xcode, Objective-C, iOS APIsSubhransu Behera
 
Tell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature FlagsTell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature FlagsJorge Ortiz
 
Objective-C Runtime overview
Objective-C Runtime overviewObjective-C Runtime overview
Objective-C Runtime overviewFantageek
 
Advanced Swift Generics
Advanced Swift GenericsAdvanced Swift Generics
Advanced Swift GenericsMax Sokolov
 
OOP, API Design and MVP
OOP, API Design and MVPOOP, API Design and MVP
OOP, API Design and MVPHarshith Keni
 
Mobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve MobileMobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve MobileKonstantin Loginov
 
Making Things Work Together
Making Things Work TogetherMaking Things Work Together
Making Things Work TogetherSubbu Allamaraju
 
iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)Netcetera
 
iOS Einführung am Beispiel von play NEXT TEE
iOS Einführung am Beispiel von play NEXT TEEiOS Einführung am Beispiel von play NEXT TEE
iOS Einführung am Beispiel von play NEXT TEEHendrik Ebel
 
Implementing new WebAPIs
Implementing new WebAPIsImplementing new WebAPIs
Implementing new WebAPIsJulian Viereck
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEBenjamin Cabé
 

Semelhante a iOS Development Overview: Core Components and Frameworks (20)

iOS
iOSiOS
iOS
 
Code camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una DalyCode camp 2011 Getting Started with IOS, Una Daly
Code camp 2011 Getting Started with IOS, Una Daly
 
iPhone Development Intro
iPhone Development IntroiPhone Development Intro
iPhone Development Intro
 
Pentesting iOS Apps - Runtime Analysis and Manipulation
Pentesting iOS Apps - Runtime Analysis and ManipulationPentesting iOS Apps - Runtime Analysis and Manipulation
Pentesting iOS Apps - Runtime Analysis and Manipulation
 
iOS,From Development to Distribution
iOS,From Development to DistributioniOS,From Development to Distribution
iOS,From Development to Distribution
 
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...
 
Pioc
PiocPioc
Pioc
 
Ios - Introduction to platform & SDK
Ios - Introduction to platform & SDKIos - Introduction to platform & SDK
Ios - Introduction to platform & SDK
 
iOS 101 - Xcode, Objective-C, iOS APIs
iOS 101 - Xcode, Objective-C, iOS APIsiOS 101 - Xcode, Objective-C, iOS APIs
iOS 101 - Xcode, Objective-C, iOS APIs
 
Tell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature FlagsTell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature Flags
 
Objective-C Runtime overview
Objective-C Runtime overviewObjective-C Runtime overview
Objective-C Runtime overview
 
Advanced Swift Generics
Advanced Swift GenericsAdvanced Swift Generics
Advanced Swift Generics
 
OOP, API Design and MVP
OOP, API Design and MVPOOP, API Design and MVP
OOP, API Design and MVP
 
Mobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve MobileMobile Developers Talks: Delve Mobile
Mobile Developers Talks: Delve Mobile
 
Making Things Work Together
Making Things Work TogetherMaking Things Work Together
Making Things Work Together
 
iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)
 
iOS Einführung am Beispiel von play NEXT TEE
iOS Einführung am Beispiel von play NEXT TEEiOS Einführung am Beispiel von play NEXT TEE
iOS Einführung am Beispiel von play NEXT TEE
 
Implementing New Web
Implementing New WebImplementing New Web
Implementing New Web
 
Implementing new WebAPIs
Implementing new WebAPIsImplementing new WebAPIs
Implementing new WebAPIs
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDE
 

Último

The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 

Último (20)

The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 

iOS Development Overview: Core Components and Frameworks

  • 2. iOS Overview Cocoa Touch Core OS Media Core Services OS X Kernel Power management Mach 3.0 Keychain Access Core OS BSD Certificates Sockets File System Security Bonjour 2
  • 3. iOS Overview Cocoa Touch Core Services Media Core Services Collections Core Location Address Book Net Services Core OS Networking Threading File Access Preferences SQLite URL Utilities 3
  • 4. iOS Overview Cocoa Touch Media Media Core Services Core Audio JPEG, PNG, TIFF OpenAL PDF Core OS Audio Mixing Quartz (2D) Audio Recording Core Animation Video Playback OpenGL 4
  • 5. iOS Overview Cocoa Touch Cocoa Touch Media Multi-touch Alerts Core Services Core Motion Web View Core OS View Hierarchy Map Kit Localization Image Picker Controls Camera 5
  • 6. Platform Components • Tools • Language [display setTextColor:[UIColor blackColor]]; • Frameworks • Design Strategies V 6
  • 7. Model View Controller Controller Model View Model – What your application is (but not how it is displayed) Controller– How your model is presented to User (UI Logic) View – Controller’s Minions 7
  • 8. iOS Application Structure App Code Boilerplate code Resources Images, Videos, Sound, IB, Data Linked Frameworks, Foundation, Graphics, Sound The Executables Targets (Various Build Settings) 8
  • 9. Application Life Cycle int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, nil); [pool release]; return retVal; } 9
  • 10. Objective C CalculatorViewController Controller action x 7 Model View 4 + operationPressed: CalculatorModel UI Buttons digitPressed: 10
  • 11. Model Header file CalculatorModel.h Model Name of the class #import <Foundation/Foundation.h> Class’s Superclass @interface CalculatorModel : NSObject { Instance Variable between the double operand; paranthesis } Return Type -(void) setOperand : (double) anOperand; -(double) performOperation : (NSString*)operation; Method declarations Name of the method Method argument @end 11
  • 12. Model Implementation File. CalculatorModel.m Model #import CalculatorModel.h @implementation CalculatorModel -(void) setOperand:(double) anOperand { operand = anOperand; } -(double) performOperation: (NSString*)operation { [ operation sendMessage:argument ]; return aDouble; } @end 12
  • 13. Controller View Controller 7 8 9 * 4 5 6 / #import <UIKit/UIKit.h> @interface CalculatorViewController : UIViewController 1 2 3 + { Model C 0 = - CalculatorModel *model; IBOutlet UILabel *display; View } -( IBAction ) digitPressed : ( UIButton *) sender; - (IBAction ) operationPressed : (UIButton *) sender; 13
  • 14. 7 8 9 * 4 5 6 / 1 2 3 + C 0 = - Controller 14
  • 15. 7 8 9 * Events • digitPressed: - operationPressed: 4 5 6 / 1 2 3 + C 0 = - 15
  • 16. Objective C - Methods - (NSArray *)shipsAtPoint:(CGPoint)bombLocation withDamage:(BOOL)damaged; Instance Methods Class Methods • Start with a dash ( - ) • Starts with a plus ( + ), used for • Normal method singletons, allocation, utilities. • Can access instance variables inside as if +(id) alloc; they were locals • Can not access instance variable inside. • can send message to self and super • Message to “Self” and “Super” mean inside something a little different. Both invoke • Example only other “class” methods. Inheritance BOOL destroyed = [ ship does not work. dropBomb:bombType at:dropPoint • Example from:height]; CalculatorModel *model = [[ CalculatorModel alloc] init]; 16
  • 17. Objective C – Instance Variables Scope By default, instance variables are @protected (only the class and subclass can access). Can be marked @private (only the class can access) or @public (anyone can access) Scope Syntax @interface MyObject: NSObject { int foo; @private int eye; int jet; @protected int bar; @public int forum; int xyz; } 17
  • 18. Obj C - Properties • Now forget everything on the previous slide •Mark all instance variable @private • Use @property and dot to access instance variables • Create methods to get/set an instance variable value @interface MyObject : NSObject { @private int eye; } Letter after “set” MUST be capitalized, otherwise dot notation will not work - (int) eye; - (void) setEye : (int) anInt; @end 18
  • 19. Obj C - Properties • @property Complier can generate get/set methods declaration with @property directive. @interface MyObject : NSObject { @private int eye; } @property int eye; - (int) eye; hidden - (void) setEye : (int) anInt; @end If “readonly” keyword is used only get method will @property (readonly) int eye; be generated. 19
  • 20. Obj C - Properties Implementation (.m) file @implementation MyObject -(int) eye{ return eye; } -(void) setEye:(int)anInt{ eye = anInt; } Compiler can generate set/get methods by using keyword @synthesize @implementation MyObject @synthesize eye; - (int)eye { return eye; } - (void)setEye:(int)anInt { eye = anInt; } @end 20
  • 21. Obj C – Dynamic Binding • All objects are allocated to heap, so use pointers • It’s legal to “cast” a pointer. • All objects inherited from NSObjects knows about • isKindOfClass • isMemberOfClass • respondToSelector 21
  • 22. Frameworks Foundation Framework • NSObject • Base class for pretty much every object in the iOS SDK. • Implements memory management primitives • NSString • Unicode • Used throughout iOS instead of C language char * • An NSString instance can not be modified. They are immutable • NSMutableString • Mutable version of NSString. • NSNumber, NSData, NSDate • NSArray, NSMutableArray • NSDictionary, NSMutableDictionary • NSSet, NSMutableSet • NSUserDefaults 22
  • 23. Creating Objects Two Step process -allocate -Initiate alloc makes space in heap for class’s instance variables. Each class has a designated “initializer” method. MyObject *obj = [ [ MyObject alloc] init]; 23
  • 24. Getting Objects alloc/init is not the only way to “get” an object. Plenty of classes give the object if you ask for it. NSString *newDisplay = [ display.text stringByAppendingString:digit ]; NSArray *keys = [ dictionary allKeys]; Who frees the memory for all these objects? No Garbage collection in iOS Answer lies in “reference counting” 24
  • 25. Reference Counting -Take the ownership for an object you want to keep a pointer to - When you are done with the object, you give up the ownership - When no one claims ownership for an object, it gets de allocated. So when do we take the ownership? Own any object as soon as we send a msg with new, alloc, or copy. But if we receive the object from any other source you don’t own it, but we can take ownership by sending it the NSObject message “retain”. The object which we receive from any other source, we’ll own it temporarily until the call stack unwinds Or, the object is retained. Once we are done with the object, send the object the NSObject message “release”. We now own theMoney, we got it using the method alloc. We are responsible for -(Money *) showMeTheMoney:(double) amount { sending it release Money *theMoney = [[ Money alloc] init:amount]; [theMoney autorelease]; We’ve now released the object but it won’t happen return Money; until the caller of this method has had chance to retain to theMoney if they want. } Caller Money *myMoney = [ bank showMeTheMoney:5000]; [myMoney retain]; 25
  • 26. Deallocation What happens when the last owner calls release? A special method, dealloc, is called on the object & the object’s memory is returned to the heap. After this happens, sending a message to the object will crash the program. Override “dealloc” in your class but NEVER call it !!! [ Strange ? ] It only gets called by release when the last owner has ‘released’ the object. The one exception about calling it is that you should call [super dealloc] in your dealloc. Example - (void) dealloc { [brain release]; [super dealloc]; } 26
  • 27. @property Example display.text = [display.text stringByAppendingString:digit]; This is still owned by display (the UILabel). We don’t This is the NSString we acquired. It comes back retain it because we are not going to keep it. We’re autoreleased. We’re not going to retain this one either just going to use it to acquire a different NSString b’cause we’re just going to pass it on to display’s text from stringByAppendingString property setter method. Setting an instance variable via setter method (via property) Did we retain that object? We need to retain instance variable and this can be done via setter methods but what about @synthesis There are 3 options for setters made by @synthesis @property (retain) NSArray *myArrayProperty; @property (copy) NSString *someNameProperty; @property (assign) id delegate; The first 2 options are straight forward. The third option means that neither retain nor copy is sent to the object passed to the setter. This means that if this object is released by all other owners, we’ll have a bad pointer. So we only use “assign” if the passed object essentially owns the object with the property. A controller and its views (b’cause a View should never outlive its controller) A View can have a property (delegate is very common) which is assigned to its controller. 27
  • 28. @property examples @property (retain) NSString *name; @synthesis will create a setter equivalent to -(void) setName:(NSString *) aString @synthesis will release the retain previous object (if any, could be { nil) before setting and retaining the [name release]; new one. name = [aString retain]; } @property (copy) NSString *name; @synthesis will create a setter equivalent to copy -(void) setName:(NSString *) aString { [name release]; name = [aString copy]; } @property (assign) NSString *name; @synthesis will create a setter equivalent to assign -(void) setName:(NSString *) aString { name = aString; } 28
  • 29. #import <Foundation/Foundation.h> @protocol ProcessDataDelegate <NSObject> @required - (void) processSuccessful: (BOOL)success; @end protocols Protocols can be useful in a number of cases, a common usage is to define method that are to be implemented by other classes. Similar to @interface, but no implementation @protocol Foo -(void) doSomething; // implementors must implement @optional -(int) getSomething; // Optional to implement. Class that implement will look like @interfaceMyClass : NSObject <Foo> … @end Use of protocols are mainly in delegates and dataSources The delegate or dataSource is always defined as an assign @property @property (assign) id <UISomeObjectDelegate> delegate; 29
  • 30. Protocols #import <Foundation/Foundation.h> #import "ClassWithProtocol.h" @protocol ProcessDataDelegate <NSObject> @implementation ClassWithProtocol -(void) processSuccessful: (BOOL)success; @synthesize delegate; @end -(void)processComplete { [[self delegate] processSuccessful:YES]; @interface ClassWithProtocol : NSObject { } id <ProcessDataDelegate> delegate; -(void)startSomeProcess { } [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(processComplete) userInfo:nil repeats:YES]; @property (retain) id delegate; } -(void)startSomeProcess; @end 30
  • 31. Application Delegate Class that adopts the protocol. HappinessAppDelegate.h (header file for Application Delegate) This object implements the UIApplicationDelegate protocol. The applicationDidxxx and applicationWillxxx @interface HappinessAppDelegate : NSObject <UIApplicationDelegate> methods { UIWindow *window; Instance Variable/property/outlet HappynessViewController *viewController; pointing to HappynessViewController } (our controller) also hooked up to MainWindow.xib @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet HappynessViewController *viewController; @end Instance Variable/property/outlet pointing to the top-level view for this application (UIWindow). This is hooked up to MainWindow.xib 31
  • 32. Adopting Protocol & Delegate #import <UIKit/UIKit.h> #import "TestAppDelegate.h" #import "ClassWithProtocol.h" #import "ClassWithProtocol.h" @implementation TestAppDelegate @interface TestAppDelegate : NSObject <UIApplicationDelegate, ProcessDataDelegate> @synthesize window; UITableViewDelegate { -(void)processSuccessful:(BOOL)success; { UIWindow *window; NSLog(@"Process completed"); ClassWithProtocol *protocolTest; } } -(void)applicationDidFinishLaunching:(UIApplication *)application @property (nonatomic, retain) UIWindow *window; { // Create and initialize the window @end window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; protocolTest = [[ClassWithProtocol alloc] init]; [protocolTest setDelegate:self]; [protocolTest startSomeProcess]; [window makeKeyAndVisible]; } -(void)dealloc { [window release]; [super dealloc]; } 32 @end