SlideShare ist ein Scribd-Unternehmen logo
1 von 105
Downloaden Sie, um offline zu lesen
iPhone App Case Study

          Stewart Gleadow
          sgleadow@thoughtworks.com
          @stewgleadow



Friday, 16 September 11
Why iPhone
                          development?


Friday, 16 September 11
YOW Conference

                    • Workshops November 28-30
                    • Conference December 1-2
                    • http://www.yowconference.com.au/
                    • lisa@yowconference.com

Friday, 16 September 11
Common features
                           in iPhone apps


Friday, 16 September 11
Outline
                    1. Basic table views
                    2. Custom table views
                    3. Dynamic content
                    4. Master/detail navigation
                    5. Make it awesome



Friday, 16 September 11
Games




Friday, 16 September 11
Camera control




Friday, 16 September 11
Basic tables




Friday, 16 September 11
Advanced tables




Friday, 16 September 11
Forms




Friday, 16 September 11
Scroll views




Friday, 16 September 11
Maps




Friday, 16 September 11
Location awareness




Friday, 16 September 11
Master/detail navigation




Friday, 16 September 11
Master/detail navigation




Friday, 16 September 11
Consuming and
                    presenting information
                        from the web


Friday, 16 September 11
Build up your toolbox




Friday, 16 September 11
Build up your toolbox




       http://cocoawithlove.com/2011/06/process-of-writing-ios-application.html




Friday, 16 September 11
Build up your toolbox




       http://cocoawithlove.com/2011/06/process-of-writing-ios-application.html




Friday, 16 September 11
1. Basic table
                              view


Friday, 16 September 11
Property
               An Objective C domain model class




Friday, 16 September 11
Property
               An Objective C domain model class

               @interface Property : NSObject

               @property (nonatomic, copy) NSString *address;
               @property (nonatomic, copy) NSString *suburb;
               @property (nonatomic, copy) NSString *postode;

               @property (nonatomic, retain) UIImage *photo;
               @property (nonatomic, copy) NSString *summary;

               - (NSString *)location;

               @end




Friday, 16 September 11
Property
               An Objective C domain model class

               @interface Property : NSObject

               @property (nonatomic, copy) NSString *address;
               @property (nonatomic, copy) NSString *suburb;
               @property (nonatomic, copy) NSString *postode;

               @property (nonatomic, retain) UIImage *photo;
               @property (nonatomic, copy) NSString *summary;

               - (NSString *)location;

               @end


                          Put logic in your model classes

Friday, 16 September 11
Property
               Make your objects easy to create and configure




Friday, 16 September 11
Property
               Make your objects easy to create and configure

               + (Property *)propertyWithAddess:(NSString *)anAddress
                                         suburb:(NSString *)aSuburb
                                       postcode:(NSString *)aPostcode
                                          photo:(NSString *)photoName
                                        summary:(NSString *)aSummary;
               {
                   Property *property = [[[Property alloc] init] autorelease];

                          property.address = anAddress;
                          property.suburb = aSuburb;
                          property.postode = aPostcode;

                          property.photo = [UIImage imageNamed:photoName];
                          property.summary = aSummary;

                          return property;
               }
Friday, 16 September 11
UIViewController



                    UITableView




Friday, 16 September 11
UIViewController



                    UITableView   UITableViewDataSource




                                  UITableViewDelegate




                                  UITableViewCell

Friday, 16 September 11
UITableView




Friday, 16 September 11
UITableView
                Creating your UITableView
                 UITableView *table;
                 table = [[UITableView alloc]
                             initWithFrame:self.view.bounds
                                     style:UITableViewStylePlain];




Friday, 16 September 11
UITableView
                Creating your UITableView
                 UITableView *table;
                 table = [[UITableView alloc]
                             initWithFrame:self.view.bounds
                                     style:UITableViewStylePlain];


                Setting up your delegates
                table.delegate = self;
                table.dataSource = self;




Friday, 16 September 11
UITableView
                Creating your UITableView
                 UITableView *table;
                 table = [[UITableView alloc]
                             initWithFrame:self.view.bounds
                                     style:UITableViewStylePlain];


                Setting up your delegates
                table.delegate = self;
                table.dataSource = self;



                Adding the table to the view
               [self.view addSubview:table];


Friday, 16 September 11
UITableView




Friday, 16 September 11
UITableView




Friday, 16 September 11
UITableViewCell




Friday, 16 September 11
UITableViewCell
          Creating a table cell
            - (id)initWithStyle:(UITableViewCellStyle)style
                reuseIdentifier:(NSString *)reuseIdentifier;




Friday, 16 September 11
UITableViewCell
          Creating a table cell
            - (id)initWithStyle:(UITableViewCellStyle)style
                reuseIdentifier:(NSString *)reuseIdentifier;


          [[UITableViewCell alloc]
                  initWithStyle:UITableViewCellStyleSubtitle
                  reuseIdentifier:@"RMITCellIdentifier"];




Friday, 16 September 11
UITableViewCell
          Creating a table cell
            - (id)initWithStyle:(UITableViewCellStyle)style
                reuseIdentifier:(NSString *)reuseIdentifier;


          [[UITableViewCell alloc]
                  initWithStyle:UITableViewCellStyleSubtitle
                  reuseIdentifier:@"RMITCellIdentifier"];

                                                   Reuse is important




Friday, 16 September 11
UITableViewCell
          Creating a table cell
            - (id)initWithStyle:(UITableViewCellStyle)style
                reuseIdentifier:(NSString *)reuseIdentifier;


          [[UITableViewCell alloc]
                  initWithStyle:UITableViewCellStyleSubtitle
                  reuseIdentifier:@"RMITCellIdentifier"];

                                                   Reuse is important

          Configuring the cell
           cell.textLabel.text = @"title string";
           cell.detailTextLabel.text = @"subtitle string";




Friday, 16 September 11
UITableViewDataSource




Friday, 16 September 11
UITableViewDataSource
          How many sections do I have?




Friday, 16 September 11
UITableViewDataSource
          How many sections do I have?
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;




Friday, 16 September 11
UITableViewDataSource
          How many sections do I have?
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;



          How many rows are in each section?




Friday, 16 September 11
UITableViewDataSource
          How many sections do I have?
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;



          How many rows are in each section?
    - (NSInteger)tableView:(UITableView *)tableView
     numberOfRowsInSection:(NSInteger)section;




Friday, 16 September 11
UITableViewDataSource
          How many sections do I have?
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;



          How many rows are in each section?
    - (NSInteger)tableView:(UITableView *)tableView
     numberOfRowsInSection:(NSInteger)section;


          What is the cell for a given row/section?




Friday, 16 September 11
UITableViewDataSource
          How many sections do I have?
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;



          How many rows are in each section?
    - (NSInteger)tableView:(UITableView *)tableView
     numberOfRowsInSection:(NSInteger)section;


          What is the cell for a given row/section?
    - (UITableViewCell *)tableView:(UITableView *)aTableView
             cellForRowAtIndexPath:(NSIndexPath *)indexPath;




Friday, 16 September 11
Demo 1:
                          Basic table view


Friday, 16 September 11
2. Custom
                          table view


Friday, 16 September 11
UITableViewCell


                                   textLabel
                    imageView
                                 detailTextLabel




Friday, 16 September 11
UITableViewCell


                                        textLabel
                    imageView
                                     detailTextLabel




                          Plus:   • backgroundView
                                  • selectedBackgroundView
                                  • contentView
Friday, 16 September 11
Customising Cells
     if (cell == nil)
     {
         cell = [[[UITableViewCell alloc]
                          initWithStyle:UITableViewCellStyleSubtitle
                          reuseIdentifier:cellIdentifier] autorelease];

               self.textLabel.backgroundColor = [UIColor clearColor];
               self.textLabel.font = [UIFont boldSystemFontOfSize:14];
               self.textLabel.shadowOffset = CGSizeMake(0, 1);

               // And a whole lot more
     }




Friday, 16 September 11
Customising Cells
     if (cell == nil)
     {
         cell = [[[UITableViewCell alloc]
                          initWithStyle:UITableViewCellStyleSubtitle
                          reuseIdentifier:cellIdentifier] autorelease];

               self.textLabel.backgroundColor = [UIColor clearColor];
               self.textLabel.font = [UIFont boldSystemFontOfSize:14];
               self.textLabel.shadowOffset = CGSizeMake(0, 1);

               // And a whole lot more
     }




Friday, 16 September 11
Customising Cells
     if (cell == nil)
     {
         cell = [[[UITableViewCell alloc]
                          initWithStyle:UITableViewCellStyleSubtitle
                          reuseIdentifier:cellIdentifier] autorelease];

               self.textLabel.backgroundColor = [UIColor clearColor];
               self.textLabel.font = [UIFont boldSystemFontOfSize:14];
               self.textLabel.shadowOffset = CGSizeMake(0, 1);

               // And a whole lot more
     }



                    Refactor into our own styled cell class



Friday, 16 September 11
PropertyCell
           A subclass of UITableViewcell




Friday, 16 September 11
PropertyCell
           A subclass of UITableViewcell
           - (id)initWithStyle:(UITableViewCellStyle)style
               reuseIdentifier:(NSString *)reuseIdentifier
           {
               if ((self = [super initWithStyle:style
                                reuseIdentifier:reuseIdentifier]))
               {
                   self.textLabel.textColor = [UIColor darkGrayColor];
                   self.textLabel.backgroundColor = [UIColor clearColor];

                          // More cell styling code goes here
                     }

                     return self;
           }




Friday, 16 September 11
Demo 2:
                          Custom table view


Friday, 16 September 11
3. Dynamic
                            content


Friday, 16 September 11
Backend server

                    • Hosted on Heroku
                          •   http://rmit-property-search.heroku.com/search


                    • Written in Ruby
                    • Uses the Sinatra framework

Friday, 16 September 11
Server code




Friday, 16 September 11
Server code

                           require 'rubygems'
                           require 'bundler'
                           require 'erb'
                           Bundler.require

                           get '/search' do
                             @search = params[:q]
                             erb :properties
                           end




Friday, 16 September 11
Server code

                           require 'rubygems'
                           require 'bundler'
                           require 'erb'
                           Bundler.require

                           get '/search' do
                             @search = params[:q]   template
                             erb :properties
                           end                      JSON file




Friday, 16 September 11
Example JSON




Friday, 16 September 11
Example JSON
                          {
                              "title" : "",
                              "properties" : [
                                  {
                                      "address" : "60-74 Buckingham Drive",
                                      "suburb" : "Heidelberg",
                                      "postcode" : "3084",
                                      "photo" : "photo1.jpg",
                                      "summary" : "Banyule House, 1839"
                                  },
                                  {
                                      "address" : "3 Macedon Street",
                                      "suburb" : "Sunbury",
                                      "postcode" : "3429" ,
                                      "photo" : "photo10.jpg",
                                      "summary" : "Rupertswood"
                                  },
                                  ...
                              ]
                    }
Friday, 16 September 11
Networking




Friday, 16 September 11
Networking
                                 Don’t reinvent
                                  the wheel




Friday, 16 September 11
Networking
                                 Don’t reinvent
                                  the wheel
                                  •   NSURLConnection

                                  •   ASIHttpRequest

                                  •   LRResty

                                  •   AFNetworking

                                  •   RestKit

Friday, 16 September 11
Networking
                                 Don’t reinvent
                                  the wheel
                                  •   NSURLConnection

                                  •   ASIHttpRequest

                                  •   LRResty

                                  •   AFNetworking

                                  •   RestKit

Friday, 16 September 11
LRResty




Friday, 16 September 11
LRResty
          Performing a GET request
          - (IBAction)search
          {
              [[LRResty client]
                  get:@"http://rmit-property-search.heroku.com/search"
                  delegate:self];
          }




Friday, 16 September 11
LRResty
          Performing a GET request
          - (IBAction)search
          {
              [[LRResty client]
                  get:@"http://rmit-property-search.heroku.com/search"
                  delegate:self];
          }



          Receiving the delegate callback
          - (void)restClient:(LRRestyClient *)client
            receivedResponse:(LRRestyResponse *)response;
          {
              NSData *data = [response responseData];

                    // convert data to property objects
          }


Friday, 16 September 11
Parsing data




Friday, 16 September 11
Parsing data
                                  Don’t reinvent
                                   the wheel




Friday, 16 September 11
Parsing data
                                  Don’t reinvent
                                   the wheel


                                   •   JSONKit

                                   •   json framework

                                   •   YAJL

Friday, 16 September 11
Parsing data
                                  Don’t reinvent
                                   the wheel


                                   •   JSONKit

                                   •   json framework

                                   •   YAJL

Friday, 16 September 11
YAJL




Friday, 16 September 11
YAJL
          Converting NSString or NSData to JSON
          - (id)yajl_JSON;




Friday, 16 September 11
YAJL
          Converting NSString or NSData to JSON
          - (id)yajl_JSON;



         Extracting property data
          NSDictionary *jsonDict = [data yajl_JSON];
          NSArray *propertiesArray = [jsonDict valueForKey:@"properties"];

          NSMutableArray *newProperties = [NSMutableArray array];

          for (NSDictionary *dict in propertiesArray)
          {
              Property *property = [Property propertyWithDictionary:dict];
              [newProperties addObject:property];
          }



Friday, 16 September 11
YAJL
          Converting NSString or NSData to JSON
          - (id)yajl_JSON;



         Extracting property data
          NSDictionary *jsonDict = [data yajl_JSON];
          NSArray *propertiesArray = [jsonDict valueForKey:@"properties"];

          NSMutableArray *newProperties = [NSMutableArray array];

          for (NSDictionary *dict in propertiesArray)
          {
              Property *property = [Property propertyWithDictionary:dict];
              [newProperties addObject:property];
          }



Friday, 16 September 11
NSDictionary -> Property




Friday, 16 September 11
NSDictionary -> Property
          Pull the values you want out of the dictionary

+ (Property *)propertyWithDictionary:(NSDictionary *)dict
{
  return [Property propertyWithAddess:[dict valueForKey:@"address"]
                               suburb:[dict valueForKey:@"suburb"]
                             postcode:[dict valueForKey:@"postcode"]
                                photo:[dict valueForKey:@"photo"]
                              summary:[dict valueForKey:@"summary"]];
}




Friday, 16 September 11
Demo 3:
                          Dynamic content


Friday, 16 September 11
4. Master/detail
                             navigation


Friday, 16 September 11
DetailViewController




Friday, 16 September 11
Creating the new view controller with a property




Friday, 16 September 11
Creating the new view controller with a property

            - (id)initWithProperty:(Property *)aProperty
            {
                if ((self = [super initWithNibName:@"DetailViewController"
                                            bundle:nil]))
                {
                    self.property = aProperty;
                    self.title = @"Property";
                }

                     return self;
            }




Friday, 16 September 11
Updating content in the DetailViewController




Friday, 16 September 11
Updating content in the DetailViewController
            - (void)viewDidLoad;
            {
                [super viewDidLoad];

                      self.address.text = self.property.address;
                      self.location.text = self.property.location;
                      self.photo.image = self.property.photo;
                      self.summary.text = self.property.summary;
            }




Friday, 16 September 11
UITableViewDelegate
         - (void)tableView:(UITableView *)tableView
         didSelectRowAtIndexPath:(NSIndexPath *)indexPath;




Friday, 16 September 11
UITableViewDelegate
         - (void)tableView:(UITableView *)tableView
         didSelectRowAtIndexPath:(NSIndexPath *)indexPath;




             •       pull out the Property object for selected row

             •       create a new DetailViewController with that Property

             •       push the new controller onto the navigation stack




Friday, 16 September 11
Demo 4:
                          Master / Detail


Friday, 16 September 11
5. Make it awesome



Friday, 16 September 11
What’s missing?




Friday, 16 September 11
What’s missing?

                    • Can’t dismiss the keyboard




Friday, 16 September 11
What’s missing?

                    • Can’t dismiss the keyboard
                    • Search does not actually search



Friday, 16 September 11
What’s missing?

                    • Can’t dismiss the keyboard
                    • Search does not actually search
                    • No progress indicator while loading


Friday, 16 September 11
What’s missing?

                    • Can’t dismiss the keyboard
                    • Search does not actually search
                    • No progress indicator while loading
                    • People like pull-to-refresh like Facebook

Friday, 16 September 11
Demo 5:
                          Making it awesome


Friday, 16 September 11
The finished product




Friday, 16 September 11
The finished product




Friday, 16 September 11
Master/detail navigation




Friday, 16 September 11
Summary
                    1. Basic table views
                    2. Custom table views
                    3. Dynamic content
                    4. Master/detail navigation
                    5. Make it awesome



Friday, 16 September 11
iPhone App Case Study

          Stewart Gleadow
          g
          sgleadow@thoughtworks.com



Friday, 16 September 11
Appendix



Friday, 16 September 11
Links

                    •     https://github.com/lukeredpath/LRResty

                    •     http://gabriel.github.com/yajl-objc/

                    •     https://github.com/jdg/MBProgressHUD

                    •     https://github.com/chpwn/PullToRefreshView

                    •     http://www.heroku.com/

                    •     http://www.sinatrarb.com/




Friday, 16 September 11
Linking static libraries
                        and frameworks




Friday, 16 September 11
Linking static libraries
                        and frameworks




               Other linker flags:   -all_load -ObjC

Friday, 16 September 11

Weitere ähnliche Inhalte

Andere mochten auch

Andere mochten auch (14)

Case study operating systems
Case study operating systemsCase study operating systems
Case study operating systems
 
Apple Case Study
Apple Case StudyApple Case Study
Apple Case Study
 
BMW creative brief
BMW creative briefBMW creative brief
BMW creative brief
 
PayPal Creative Brief
PayPal Creative BriefPayPal Creative Brief
PayPal Creative Brief
 
Android vs. IOS: Comparing features & functions
Android vs. IOS: Comparing features & functionsAndroid vs. IOS: Comparing features & functions
Android vs. IOS: Comparing features & functions
 
Apple in 2010 - Harvard Case Analysis
Apple in 2010 - Harvard Case AnalysisApple in 2010 - Harvard Case Analysis
Apple in 2010 - Harvard Case Analysis
 
Red Bull Creative Brief
Red Bull Creative BriefRed Bull Creative Brief
Red Bull Creative Brief
 
Creative Brief Example
Creative Brief ExampleCreative Brief Example
Creative Brief Example
 
iOS design: a case study
iOS design: a case studyiOS design: a case study
iOS design: a case study
 
Creative brief
Creative briefCreative brief
Creative brief
 
Apple inc. Strategic Case Analysis Presentation
Apple inc. Strategic Case Analysis PresentationApple inc. Strategic Case Analysis Presentation
Apple inc. Strategic Case Analysis Presentation
 
Apple inc. Strategic Case Analysis
Apple inc. Strategic Case AnalysisApple inc. Strategic Case Analysis
Apple inc. Strategic Case Analysis
 
The Creative Brief: An Introduction
The Creative Brief: An IntroductionThe Creative Brief: An Introduction
The Creative Brief: An Introduction
 
Business Plan - Mobile Application Development
Business Plan - Mobile Application DevelopmentBusiness Plan - Mobile Application Development
Business Plan - Mobile Application Development
 

Ähnlich wie iOS app case study (6)

SkinKit
SkinKitSkinKit
SkinKit
 
My Favourite 10 Things about Xcode/ObjectiveC
My Favourite 10 Things about Xcode/ObjectiveCMy Favourite 10 Things about Xcode/ObjectiveC
My Favourite 10 Things about Xcode/ObjectiveC
 
Formacion en movilidad: Conceptos de desarrollo en iOS (III)
Formacion en movilidad: Conceptos de desarrollo en iOS (III) Formacion en movilidad: Conceptos de desarrollo en iOS (III)
Formacion en movilidad: Conceptos de desarrollo en iOS (III)
 
Core Animation
Core AnimationCore Animation
Core Animation
 
Cocoaheads Montpellier Meetup : 3D Touch for iOS
Cocoaheads Montpellier Meetup : 3D Touch for iOSCocoaheads Montpellier Meetup : 3D Touch for iOS
Cocoaheads Montpellier Meetup : 3D Touch for iOS
 
Desenvolvimento iOS - Aula 4
Desenvolvimento iOS - Aula 4Desenvolvimento iOS - Aula 4
Desenvolvimento iOS - Aula 4
 

Mehr von sgleadow

Mehr von sgleadow (11)

Evolving Mobile Architectures @ Mi9
Evolving Mobile Architectures @ Mi9Evolving Mobile Architectures @ Mi9
Evolving Mobile Architectures @ Mi9
 
Evolving for Multiple Screens
Evolving for Multiple ScreensEvolving for Multiple Screens
Evolving for Multiple Screens
 
Mobile: more than just an app
Mobile: more than just an appMobile: more than just an app
Mobile: more than just an app
 
Evolving Mobile Architectures
Evolving Mobile ArchitecturesEvolving Mobile Architectures
Evolving Mobile Architectures
 
Building mobile teams and getting a product to market
Building mobile teams and getting a product to marketBuilding mobile teams and getting a product to market
Building mobile teams and getting a product to market
 
iOS Unit Testing
iOS Unit TestingiOS Unit Testing
iOS Unit Testing
 
Agile iOS
Agile iOSAgile iOS
Agile iOS
 
Frank iOS Testing
Frank iOS TestingFrank iOS Testing
Frank iOS Testing
 
Multithreaded Data Transport
Multithreaded Data TransportMultithreaded Data Transport
Multithreaded Data Transport
 
A few design patterns
A few design patternsA few design patterns
A few design patterns
 
GPU Programming
GPU ProgrammingGPU Programming
GPU Programming
 

Kürzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

iOS app case study

  • 1. iPhone App Case Study Stewart Gleadow sgleadow@thoughtworks.com @stewgleadow Friday, 16 September 11
  • 2. Why iPhone development? Friday, 16 September 11
  • 3. YOW Conference • Workshops November 28-30 • Conference December 1-2 • http://www.yowconference.com.au/ • lisa@yowconference.com Friday, 16 September 11
  • 4. Common features in iPhone apps Friday, 16 September 11
  • 5. Outline 1. Basic table views 2. Custom table views 3. Dynamic content 4. Master/detail navigation 5. Make it awesome Friday, 16 September 11
  • 8. Basic tables Friday, 16 September 11
  • 11. Scroll views Friday, 16 September 11
  • 16. Consuming and presenting information from the web Friday, 16 September 11
  • 17. Build up your toolbox Friday, 16 September 11
  • 18. Build up your toolbox http://cocoawithlove.com/2011/06/process-of-writing-ios-application.html Friday, 16 September 11
  • 19. Build up your toolbox http://cocoawithlove.com/2011/06/process-of-writing-ios-application.html Friday, 16 September 11
  • 20. 1. Basic table view Friday, 16 September 11
  • 21. Property An Objective C domain model class Friday, 16 September 11
  • 22. Property An Objective C domain model class @interface Property : NSObject @property (nonatomic, copy) NSString *address; @property (nonatomic, copy) NSString *suburb; @property (nonatomic, copy) NSString *postode; @property (nonatomic, retain) UIImage *photo; @property (nonatomic, copy) NSString *summary; - (NSString *)location; @end Friday, 16 September 11
  • 23. Property An Objective C domain model class @interface Property : NSObject @property (nonatomic, copy) NSString *address; @property (nonatomic, copy) NSString *suburb; @property (nonatomic, copy) NSString *postode; @property (nonatomic, retain) UIImage *photo; @property (nonatomic, copy) NSString *summary; - (NSString *)location; @end Put logic in your model classes Friday, 16 September 11
  • 24. Property Make your objects easy to create and configure Friday, 16 September 11
  • 25. Property Make your objects easy to create and configure + (Property *)propertyWithAddess:(NSString *)anAddress suburb:(NSString *)aSuburb postcode:(NSString *)aPostcode photo:(NSString *)photoName summary:(NSString *)aSummary; { Property *property = [[[Property alloc] init] autorelease]; property.address = anAddress; property.suburb = aSuburb; property.postode = aPostcode; property.photo = [UIImage imageNamed:photoName]; property.summary = aSummary; return property; } Friday, 16 September 11
  • 26. UIViewController UITableView Friday, 16 September 11
  • 27. UIViewController UITableView UITableViewDataSource UITableViewDelegate UITableViewCell Friday, 16 September 11
  • 29. UITableView Creating your UITableView UITableView *table; table = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; Friday, 16 September 11
  • 30. UITableView Creating your UITableView UITableView *table; table = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; Setting up your delegates table.delegate = self; table.dataSource = self; Friday, 16 September 11
  • 31. UITableView Creating your UITableView UITableView *table; table = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; Setting up your delegates table.delegate = self; table.dataSource = self; Adding the table to the view [self.view addSubview:table]; Friday, 16 September 11
  • 35. UITableViewCell Creating a table cell - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier; Friday, 16 September 11
  • 36. UITableViewCell Creating a table cell - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier; [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"RMITCellIdentifier"]; Friday, 16 September 11
  • 37. UITableViewCell Creating a table cell - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier; [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"RMITCellIdentifier"]; Reuse is important Friday, 16 September 11
  • 38. UITableViewCell Creating a table cell - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier; [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"RMITCellIdentifier"]; Reuse is important Configuring the cell cell.textLabel.text = @"title string"; cell.detailTextLabel.text = @"subtitle string"; Friday, 16 September 11
  • 40. UITableViewDataSource How many sections do I have? Friday, 16 September 11
  • 41. UITableViewDataSource How many sections do I have? - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView; Friday, 16 September 11
  • 42. UITableViewDataSource How many sections do I have? - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView; How many rows are in each section? Friday, 16 September 11
  • 43. UITableViewDataSource How many sections do I have? - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView; How many rows are in each section? - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; Friday, 16 September 11
  • 44. UITableViewDataSource How many sections do I have? - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView; How many rows are in each section? - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; What is the cell for a given row/section? Friday, 16 September 11
  • 45. UITableViewDataSource How many sections do I have? - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView; How many rows are in each section? - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; What is the cell for a given row/section? - (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; Friday, 16 September 11
  • 46. Demo 1: Basic table view Friday, 16 September 11
  • 47. 2. Custom table view Friday, 16 September 11
  • 48. UITableViewCell textLabel imageView detailTextLabel Friday, 16 September 11
  • 49. UITableViewCell textLabel imageView detailTextLabel Plus: • backgroundView • selectedBackgroundView • contentView Friday, 16 September 11
  • 50. Customising Cells if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier] autorelease]; self.textLabel.backgroundColor = [UIColor clearColor]; self.textLabel.font = [UIFont boldSystemFontOfSize:14]; self.textLabel.shadowOffset = CGSizeMake(0, 1); // And a whole lot more } Friday, 16 September 11
  • 51. Customising Cells if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier] autorelease]; self.textLabel.backgroundColor = [UIColor clearColor]; self.textLabel.font = [UIFont boldSystemFontOfSize:14]; self.textLabel.shadowOffset = CGSizeMake(0, 1); // And a whole lot more } Friday, 16 September 11
  • 52. Customising Cells if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier] autorelease]; self.textLabel.backgroundColor = [UIColor clearColor]; self.textLabel.font = [UIFont boldSystemFontOfSize:14]; self.textLabel.shadowOffset = CGSizeMake(0, 1); // And a whole lot more } Refactor into our own styled cell class Friday, 16 September 11
  • 53. PropertyCell A subclass of UITableViewcell Friday, 16 September 11
  • 54. PropertyCell A subclass of UITableViewcell - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { self.textLabel.textColor = [UIColor darkGrayColor]; self.textLabel.backgroundColor = [UIColor clearColor]; // More cell styling code goes here } return self; } Friday, 16 September 11
  • 55. Demo 2: Custom table view Friday, 16 September 11
  • 56. 3. Dynamic content Friday, 16 September 11
  • 57. Backend server • Hosted on Heroku • http://rmit-property-search.heroku.com/search • Written in Ruby • Uses the Sinatra framework Friday, 16 September 11
  • 58. Server code Friday, 16 September 11
  • 59. Server code require 'rubygems' require 'bundler' require 'erb' Bundler.require get '/search' do @search = params[:q] erb :properties end Friday, 16 September 11
  • 60. Server code require 'rubygems' require 'bundler' require 'erb' Bundler.require get '/search' do @search = params[:q] template erb :properties end JSON file Friday, 16 September 11
  • 61. Example JSON Friday, 16 September 11
  • 62. Example JSON { "title" : "", "properties" : [ { "address" : "60-74 Buckingham Drive", "suburb" : "Heidelberg", "postcode" : "3084", "photo" : "photo1.jpg", "summary" : "Banyule House, 1839" }, { "address" : "3 Macedon Street", "suburb" : "Sunbury", "postcode" : "3429" , "photo" : "photo10.jpg", "summary" : "Rupertswood" }, ... ] } Friday, 16 September 11
  • 64. Networking Don’t reinvent the wheel Friday, 16 September 11
  • 65. Networking Don’t reinvent the wheel • NSURLConnection • ASIHttpRequest • LRResty • AFNetworking • RestKit Friday, 16 September 11
  • 66. Networking Don’t reinvent the wheel • NSURLConnection • ASIHttpRequest • LRResty • AFNetworking • RestKit Friday, 16 September 11
  • 68. LRResty Performing a GET request - (IBAction)search { [[LRResty client] get:@"http://rmit-property-search.heroku.com/search" delegate:self]; } Friday, 16 September 11
  • 69. LRResty Performing a GET request - (IBAction)search { [[LRResty client] get:@"http://rmit-property-search.heroku.com/search" delegate:self]; } Receiving the delegate callback - (void)restClient:(LRRestyClient *)client receivedResponse:(LRRestyResponse *)response; { NSData *data = [response responseData]; // convert data to property objects } Friday, 16 September 11
  • 70. Parsing data Friday, 16 September 11
  • 71. Parsing data Don’t reinvent the wheel Friday, 16 September 11
  • 72. Parsing data Don’t reinvent the wheel • JSONKit • json framework • YAJL Friday, 16 September 11
  • 73. Parsing data Don’t reinvent the wheel • JSONKit • json framework • YAJL Friday, 16 September 11
  • 75. YAJL Converting NSString or NSData to JSON - (id)yajl_JSON; Friday, 16 September 11
  • 76. YAJL Converting NSString or NSData to JSON - (id)yajl_JSON; Extracting property data NSDictionary *jsonDict = [data yajl_JSON]; NSArray *propertiesArray = [jsonDict valueForKey:@"properties"]; NSMutableArray *newProperties = [NSMutableArray array]; for (NSDictionary *dict in propertiesArray) { Property *property = [Property propertyWithDictionary:dict]; [newProperties addObject:property]; } Friday, 16 September 11
  • 77. YAJL Converting NSString or NSData to JSON - (id)yajl_JSON; Extracting property data NSDictionary *jsonDict = [data yajl_JSON]; NSArray *propertiesArray = [jsonDict valueForKey:@"properties"]; NSMutableArray *newProperties = [NSMutableArray array]; for (NSDictionary *dict in propertiesArray) { Property *property = [Property propertyWithDictionary:dict]; [newProperties addObject:property]; } Friday, 16 September 11
  • 79. NSDictionary -> Property Pull the values you want out of the dictionary + (Property *)propertyWithDictionary:(NSDictionary *)dict { return [Property propertyWithAddess:[dict valueForKey:@"address"] suburb:[dict valueForKey:@"suburb"] postcode:[dict valueForKey:@"postcode"] photo:[dict valueForKey:@"photo"] summary:[dict valueForKey:@"summary"]]; } Friday, 16 September 11
  • 80. Demo 3: Dynamic content Friday, 16 September 11
  • 81. 4. Master/detail navigation Friday, 16 September 11
  • 83. Creating the new view controller with a property Friday, 16 September 11
  • 84. Creating the new view controller with a property - (id)initWithProperty:(Property *)aProperty { if ((self = [super initWithNibName:@"DetailViewController" bundle:nil])) { self.property = aProperty; self.title = @"Property"; } return self; } Friday, 16 September 11
  • 85. Updating content in the DetailViewController Friday, 16 September 11
  • 86. Updating content in the DetailViewController - (void)viewDidLoad; { [super viewDidLoad]; self.address.text = self.property.address; self.location.text = self.property.location; self.photo.image = self.property.photo; self.summary.text = self.property.summary; } Friday, 16 September 11
  • 87. UITableViewDelegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; Friday, 16 September 11
  • 88. UITableViewDelegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; • pull out the Property object for selected row • create a new DetailViewController with that Property • push the new controller onto the navigation stack Friday, 16 September 11
  • 89. Demo 4: Master / Detail Friday, 16 September 11
  • 90. 5. Make it awesome Friday, 16 September 11
  • 92. What’s missing? • Can’t dismiss the keyboard Friday, 16 September 11
  • 93. What’s missing? • Can’t dismiss the keyboard • Search does not actually search Friday, 16 September 11
  • 94. What’s missing? • Can’t dismiss the keyboard • Search does not actually search • No progress indicator while loading Friday, 16 September 11
  • 95. What’s missing? • Can’t dismiss the keyboard • Search does not actually search • No progress indicator while loading • People like pull-to-refresh like Facebook Friday, 16 September 11
  • 96. Demo 5: Making it awesome Friday, 16 September 11
  • 97. The finished product Friday, 16 September 11
  • 98. The finished product Friday, 16 September 11
  • 100. Summary 1. Basic table views 2. Custom table views 3. Dynamic content 4. Master/detail navigation 5. Make it awesome Friday, 16 September 11
  • 101. iPhone App Case Study Stewart Gleadow g sgleadow@thoughtworks.com Friday, 16 September 11
  • 103. Links • https://github.com/lukeredpath/LRResty • http://gabriel.github.com/yajl-objc/ • https://github.com/jdg/MBProgressHUD • https://github.com/chpwn/PullToRefreshView • http://www.heroku.com/ • http://www.sinatrarb.com/ Friday, 16 September 11
  • 104. Linking static libraries and frameworks Friday, 16 September 11
  • 105. Linking static libraries and frameworks Other linker flags: -all_load -ObjC Friday, 16 September 11