SlideShare a Scribd company logo
iOS REST Client
Paul Lynch
@pauldlynch, paul@plsys.co.uk
• Architecture of iOS apps
• Comet Architecture
• Model Implementation
• Controller Implementation
• Other iOS Concepts
iOS REST Client
Architecture of iOS apps
• MVC - Model/View/Controller
• Objective C
• Foundation
• UIKit - UIApplication, UIViewController, UIView, UIControl
Foundation
• NSArray, NSDictionary, NSSet
• NSValue
• NSPredicate
UIKit - UIApplication
• UIApplication
• status bar
• window
• orientation
• AppDelegate
applicationDidFinishLaunchingWithOptions:
notifications - UIApplicationWillEnterForegroundNotification,
UIApplicationDidEnterBackgroundNotification
UIView
• animations
• gestures
View Controllers
• - (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle
• navigationController, tabBarController
• rotation, transitions
• subclasses - e.g. UITableViewController
TableViews
• UITableViewController
• UITableView
• data source
• delegate
• UITableViewCell
Table view data source
@protocol UITableViewDataSource<NSObject>
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section;
...
@end
@interface NSIndexPath (UITableView)
+ (NSIndexPath *)indexPathForRow:(NSInteger)row inSection:(NSInteger)section;
@property(nonatomic,readonly) NSInteger section;
@property(nonatomic,readonly) NSInteger row;
@end
Table view delegate
@protocol UITableViewDelegate<NSObject, UIScrollViewDelegate>
...
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath;
...
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
...
@end
Comet Architecture
Comet Architecture
Marketing
db
Reviews
WO db
XML
Linux, mySQL
Change
Report
Mobile
clients
Comet Database
Features: skunum, runId; xml/json held as strings
Category
SKU
Review WC7SKU
Client
REST API
• category - parent, children
• sku
• skudetail - contains full review and XML text
• brand - attribute of sku
ERREST Routes
	 	 routeRequestHandler.addRoute(new ERXRoute(Sku.ENTITY_NAME, "/sku", ERXRoute.Method.Options, SkuController.class,
"options"));
	 	 routeRequestHandler.addRoute(new ERXRoute(Sku.ENTITY_NAME, "/sku", ERXRoute.Method.Head, SkuController.class, "head"));
	 	 routeRequestHandler.addRoute(new ERXRoute(Sku.ENTITY_NAME, "/sku", ERXRoute.Method.All, SkuController.class, "index"));
	 	 // MS: this only works with numeric ids
	 	 routeRequestHandler.addRoute(new ERXRoute(Sku.ENTITY_NAME, "/sku/{action:identifier}", ERXRoute.Method.Get, SkuController.class));
	 	 routeRequestHandler.addRoute(new ERXRoute(Sku.ENTITY_NAME, "/sku/{sku:Sku}", ERXRoute.Method.Get, SkuController.class, "show"));
	 	 routeRequestHandler.addRoute(new ERXRoute(Sku.ENTITY_NAME, "/sku/{sku:Sku}/{action:identifier}", ERXRoute.Method.All,
SkuController.class));
plus Category, Brand, Skudetail
Model Implementation
• PLRestful
• CometAPI
• Sku (etc)
PLRestful
typedef void (^PLRestfulAPICompletionBlock)(PLRestful *api, id object, NSInteger status, NSError *error);
@interface PLRestful : NSObject
@property (nonatomic, copy) NSString *endpoint;
@property (nonatomic, copy) PLRestfulAPICompletionBlock completionBlock;
@property (nonatomic, copy) NSString *username;
@property (nonatomic, copy) NSString *password;
@property (nonatomic, assign) BOOL useBasicAuthentication;
+ (NSString *)messageForStatus:(NSInteger)status;
+ (BOOL)checkReachability:(NSURL *)url;
+ (void)get:(NSString *)requestPath parameters:(NSDictionary *)parameters completionBlock:(PLRestfulAPICompletionBlock)completion;
+ (void)post:(NSString *)requestPath content:(NSDictionary *)content completionBlock:(PLRestfulAPICompletionBlock)completion;
- (void)get:(NSString *)requestPath parameters:(NSDictionary *)parameters completionBlock:(PLRestfulAPICompletionBlock)completion;
- (void)post:(NSString *)requestPath content:(NSDictionary *)content completionBlock:(PLRestfulAPICompletionBlock)completion;
@end
PLRestful - get
- (void)get:(NSString *)requestString parameters:(NSDictionary *)parameters completionBlock:
(PLRestfulAPICompletionBlock)completion {
NSURL *requestURL = [[NSURL URLWithString:endpoint] urlByAddingPath:requestString parameters:parameters];
NSLog(@"get: '%@'", [requestURL absoluteString]);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:requestURL];
[request setHTTPMethod:@"GET"];
[self handleRequest:request completion:(PLRestfulAPICompletionBlock)completion];
}
PLRestful - post
- (void)post:(NSString *)requestString content:(NSDictionary *)content completionBlock:(PLRestfulAPICompletionBlock)completion {
NSURL *requestURL = [[NSURL URLWithString:endpoint] urlByAddingPath:requestString parameters:nil];
NSLog(@"post: '%@'", [requestURL absoluteString]);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:requestURL];
[request setHTTPMethod:@"POST"];
NSError *error = nil;
request.HTTPBody = [NSJSONSerialization dataWithJSONObject:content options:0 error:&error];
if (error) {
NSLog(@"json generation failed: %@", error);
[self callCompletionBlockWithObject:nil status:0 error:[NSError errorWithDomain:@"com.plsys.semaphore.CometAPI" code:1003 userInfo:nil]];
return;
}
[self handleRequest:request completion:completion];
}
Controller Implementation
• SkuController
• subclass of UITableViewController
SkuController - data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [skus count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *sku = [skus objectAtIndex:indexPath.row];
static NSString *CellIdentifier = @"SkuCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}
// Configure the cell...
cell.textLabel.text = [[sku valueForKey:@"productName"] pl_stringByStrippingHTML];
cell.detailTextLabel.text = [sku valueForKey:@"skuNum"];
id image = [images objectAtIndex:indexPath.row];
if ([image isKindOfClass:[UIImage class]]) {
cell.imageView.image = image;
}
return cell;
}
SkuController - tv delegate
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
NSDictionary *sku = [skus objectAtIndex:indexPath.row];
NSString *skuNum = [[sku valueForKey:@"skuNum"] copy];
NSLog(@"tapped: %@", skuNum);
SkuDetail *view = [[SkuDetail alloc] initWithStyle:UITableViewStylePlain];
view.sku = sku;
view.image = [images objectAtIndex:indexPath.row];
[self.navigationController pushViewController:view animated:YES];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self tableView:tableView accessoryButtonTappedForRowWithIndexPath:indexPath];
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == ((batch + 1)*25)-1) {
// time to fetch more
self.batch = ++batch;
NSMutableDictionary *batchParameters = [parameters mutableCopy];
if (!batchParameters) batchParameters = [NSMutableDictionary dictionary];
[batchParameters setObject:[NSNumber numberWithInt:batch] forKey:@"batch"];
NSLog(@"batchParameters %@", batchParameters);
[CometAPI get:query parameters:batchParameters completionBlock:^(PLRestful *api, id object, NSInteger status, NSError *error) {
if (error) [self handleError:error];
else {
[self didAddSkus:object];
}
}];
}
}
Other iOS Topics
• Human Interface Guidelines
• Buttons - 44x44
• Gestures
• Controllers - mail, movie, picker
• Other UIControls - switch, slider, page control
• iOS 7
Code Example
• SOE Status
• http://github.com/pauldlynch/SOEStatus
• older version, will update soon
Q&A
Paul Lynch
paul@plsys.co.uk
@pauldlynch

More Related Content

PDF
ERGroupware
PDF
Beginning icloud development - Cesare Rocchi - WhyMCA
PPTX
20141001 delapsley-oc-openstack-final
PPTX
Client-side Rendering with AngularJS
KEY
iOS5 NewStuff
PPTX
OpenStack Horizon: Controlling the Cloud using Django
PDF
MPD2011 | Сергей Клюев "RESTfull iOS with RestKit"
PPTX
Omnisearch in AEM 6.2 - Search All the Things
ERGroupware
Beginning icloud development - Cesare Rocchi - WhyMCA
20141001 delapsley-oc-openstack-final
Client-side Rendering with AngularJS
iOS5 NewStuff
OpenStack Horizon: Controlling the Cloud using Django
MPD2011 | Сергей Клюев "RESTfull iOS with RestKit"
Omnisearch in AEM 6.2 - Search All the Things

What's hot (19)

PDF
Core Data with multiple managed object contexts
KEY
iOSDevCamp 2011 Core Data
PPTX
Oak Lucene Indexes
PPTX
20141002 delapsley-socalangularjs-final
PDF
Taming the beast - how to tame React & GraphQL, one error at a time
PPTX
20140821 delapsley-cloudopen-public
PDF
High Performance Core Data
PDF
20120121
PPTX
Full stack development with node and NoSQL - All Things Open - October 2017
PDF
Create a Core Data Observer in 10mins
PPTX
Demystifying Oak Search
PDF
Memory Management on iOS
PDF
Persisting Data on SQLite using Room
ZIP
iOS Memory Management Basics
PPT
Memory management in Objective C
PDF
Javascript Application Architecture with Backbone.JS
PDF
Adventures in Multithreaded Core Data
PDF
Using redux and angular 2 with meteor
PDF
Arquitetando seu aplicativo Android com Jetpack
Core Data with multiple managed object contexts
iOSDevCamp 2011 Core Data
Oak Lucene Indexes
20141002 delapsley-socalangularjs-final
Taming the beast - how to tame React & GraphQL, one error at a time
20140821 delapsley-cloudopen-public
High Performance Core Data
20120121
Full stack development with node and NoSQL - All Things Open - October 2017
Create a Core Data Observer in 10mins
Demystifying Oak Search
Memory Management on iOS
Persisting Data on SQLite using Room
iOS Memory Management Basics
Memory management in Objective C
Javascript Application Architecture with Backbone.JS
Adventures in Multithreaded Core Data
Using redux and angular 2 with meteor
Arquitetando seu aplicativo Android com Jetpack
Ad

Viewers also liked (18)

PDF
Migrating existing Projects to Wonder
PDF
Build and deployment
PDF
Reenabling SOAP using ERJaxWS
PDF
iOS for ERREST
PDF
Filtering data with D2W
PDF
Unit Testing with WOUnit
PDF
Advanced Apache Cayenne
PDF
Apache Cayenne for WO Devs
PDF
PDF
D2W Stateful Controllers
PDF
Life outside WO
PDF
Chaining the Beast - Testing Wonder Applications in the Real World
PDF
Using Nagios to monitor your WO systems
PDF
Deploying WO on Windows
PDF
KAAccessControl
PDF
High availability
PDF
"Framework Principal" pattern
PDF
In memory OLAP engine
Migrating existing Projects to Wonder
Build and deployment
Reenabling SOAP using ERJaxWS
iOS for ERREST
Filtering data with D2W
Unit Testing with WOUnit
Advanced Apache Cayenne
Apache Cayenne for WO Devs
D2W Stateful Controllers
Life outside WO
Chaining the Beast - Testing Wonder Applications in the Real World
Using Nagios to monitor your WO systems
Deploying WO on Windows
KAAccessControl
High availability
"Framework Principal" pattern
In memory OLAP engine
Ad

Similar to iOS for ERREST - alternative version (20)

PDF
Three20
PDF
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
KEY
Introduction to Restkit
KEY
UIWebView Tips
ZIP
iPhone and Rails integration
KEY
Objective-C Crash Course for Web Developers
PDF
20111030i phonedeveloperworkshoppublished
PDF
Developing iOS REST Applications
PDF
201104 iphone navigation-based apps
KEY
Mobile Development 101
PDF
303 TANSTAAFL: Using Open Source iPhone UI Code
PDF
I Phone On Rails
PDF
Three20 framework for iOS development
PPT
iphone presentation
KEY
I phone勉強会 (2011.11.23)
PDF
iOS Contact List Application Tutorial
PDF
Elements for an iOS Backend
PDF
Rails and iOS with RestKit
PDF
3D Touch by Karol Kozub, Macoscope
PDF
Lightning Talk: Mobile Cloud Jargon: Why is my iOS simulator not charging to ...
Three20
Hızlı Cocoa Geliştirme (Develop your next cocoa app faster!)
Introduction to Restkit
UIWebView Tips
iPhone and Rails integration
Objective-C Crash Course for Web Developers
20111030i phonedeveloperworkshoppublished
Developing iOS REST Applications
201104 iphone navigation-based apps
Mobile Development 101
303 TANSTAAFL: Using Open Source iPhone UI Code
I Phone On Rails
Three20 framework for iOS development
iphone presentation
I phone勉強会 (2011.11.23)
iOS Contact List Application Tutorial
Elements for an iOS Backend
Rails and iOS with RestKit
3D Touch by Karol Kozub, Macoscope
Lightning Talk: Mobile Cloud Jargon: Why is my iOS simulator not charging to ...

More from WO Community (11)

PDF
Localizing your apps for multibyte languages
PDF
PDF
D2W Branding Using jQuery ThemeRoller
PDF
CMS / BLOG and SnoWOman
PDF
Using GIT
PDF
Persistent Session Storage
PDF
Back2 future
PDF
WebObjects Optimization
PDF
Dynamic Elements
PDF
Practical ERSync
PDF
ERRest: the Basics
Localizing your apps for multibyte languages
D2W Branding Using jQuery ThemeRoller
CMS / BLOG and SnoWOman
Using GIT
Persistent Session Storage
Back2 future
WebObjects Optimization
Dynamic Elements
Practical ERSync
ERRest: the Basics

Recently uploaded (20)

PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Big Data Technologies - Introduction.pptx
PDF
cuic standard and advanced reporting.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Cloud computing and distributed systems.
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Big Data Technologies - Introduction.pptx
cuic standard and advanced reporting.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
The AUB Centre for AI in Media Proposal.docx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Cloud computing and distributed systems.
Spectral efficient network and resource selection model in 5G networks
Understanding_Digital_Forensics_Presentation.pptx
Machine learning based COVID-19 study performance prediction
NewMind AI Weekly Chronicles - August'25 Week I
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Unlocking AI with Model Context Protocol (MCP)
Building Integrated photovoltaic BIPV_UPV.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf

iOS for ERREST - alternative version

  • 1. iOS REST Client Paul Lynch @pauldlynch, paul@plsys.co.uk
  • 2. • Architecture of iOS apps • Comet Architecture • Model Implementation • Controller Implementation • Other iOS Concepts iOS REST Client
  • 3. Architecture of iOS apps • MVC - Model/View/Controller • Objective C • Foundation • UIKit - UIApplication, UIViewController, UIView, UIControl
  • 4. Foundation • NSArray, NSDictionary, NSSet • NSValue • NSPredicate
  • 5. UIKit - UIApplication • UIApplication • status bar • window • orientation • AppDelegate applicationDidFinishLaunchingWithOptions: notifications - UIApplicationWillEnterForegroundNotification, UIApplicationDidEnterBackgroundNotification
  • 7. View Controllers • - (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle • navigationController, tabBarController • rotation, transitions • subclasses - e.g. UITableViewController
  • 8. TableViews • UITableViewController • UITableView • data source • delegate • UITableViewCell
  • 9. Table view data source @protocol UITableViewDataSource<NSObject> - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView; - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section; - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section; ... @end @interface NSIndexPath (UITableView) + (NSIndexPath *)indexPathForRow:(NSInteger)row inSection:(NSInteger)section; @property(nonatomic,readonly) NSInteger section; @property(nonatomic,readonly) NSInteger row; @end
  • 10. Table view delegate @protocol UITableViewDelegate<NSObject, UIScrollViewDelegate> ... - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath; ... - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; ... @end
  • 12. Comet Architecture Marketing db Reviews WO db XML Linux, mySQL Change Report Mobile clients
  • 13. Comet Database Features: skunum, runId; xml/json held as strings Category SKU Review WC7SKU Client
  • 14. REST API • category - parent, children • sku • skudetail - contains full review and XML text • brand - attribute of sku
  • 15. ERREST Routes routeRequestHandler.addRoute(new ERXRoute(Sku.ENTITY_NAME, "/sku", ERXRoute.Method.Options, SkuController.class, "options")); routeRequestHandler.addRoute(new ERXRoute(Sku.ENTITY_NAME, "/sku", ERXRoute.Method.Head, SkuController.class, "head")); routeRequestHandler.addRoute(new ERXRoute(Sku.ENTITY_NAME, "/sku", ERXRoute.Method.All, SkuController.class, "index")); // MS: this only works with numeric ids routeRequestHandler.addRoute(new ERXRoute(Sku.ENTITY_NAME, "/sku/{action:identifier}", ERXRoute.Method.Get, SkuController.class)); routeRequestHandler.addRoute(new ERXRoute(Sku.ENTITY_NAME, "/sku/{sku:Sku}", ERXRoute.Method.Get, SkuController.class, "show")); routeRequestHandler.addRoute(new ERXRoute(Sku.ENTITY_NAME, "/sku/{sku:Sku}/{action:identifier}", ERXRoute.Method.All, SkuController.class)); plus Category, Brand, Skudetail
  • 16. Model Implementation • PLRestful • CometAPI • Sku (etc)
  • 17. PLRestful typedef void (^PLRestfulAPICompletionBlock)(PLRestful *api, id object, NSInteger status, NSError *error); @interface PLRestful : NSObject @property (nonatomic, copy) NSString *endpoint; @property (nonatomic, copy) PLRestfulAPICompletionBlock completionBlock; @property (nonatomic, copy) NSString *username; @property (nonatomic, copy) NSString *password; @property (nonatomic, assign) BOOL useBasicAuthentication; + (NSString *)messageForStatus:(NSInteger)status; + (BOOL)checkReachability:(NSURL *)url; + (void)get:(NSString *)requestPath parameters:(NSDictionary *)parameters completionBlock:(PLRestfulAPICompletionBlock)completion; + (void)post:(NSString *)requestPath content:(NSDictionary *)content completionBlock:(PLRestfulAPICompletionBlock)completion; - (void)get:(NSString *)requestPath parameters:(NSDictionary *)parameters completionBlock:(PLRestfulAPICompletionBlock)completion; - (void)post:(NSString *)requestPath content:(NSDictionary *)content completionBlock:(PLRestfulAPICompletionBlock)completion; @end
  • 18. PLRestful - get - (void)get:(NSString *)requestString parameters:(NSDictionary *)parameters completionBlock: (PLRestfulAPICompletionBlock)completion { NSURL *requestURL = [[NSURL URLWithString:endpoint] urlByAddingPath:requestString parameters:parameters]; NSLog(@"get: '%@'", [requestURL absoluteString]); NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:requestURL]; [request setHTTPMethod:@"GET"]; [self handleRequest:request completion:(PLRestfulAPICompletionBlock)completion]; }
  • 19. PLRestful - post - (void)post:(NSString *)requestString content:(NSDictionary *)content completionBlock:(PLRestfulAPICompletionBlock)completion { NSURL *requestURL = [[NSURL URLWithString:endpoint] urlByAddingPath:requestString parameters:nil]; NSLog(@"post: '%@'", [requestURL absoluteString]); NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:requestURL]; [request setHTTPMethod:@"POST"]; NSError *error = nil; request.HTTPBody = [NSJSONSerialization dataWithJSONObject:content options:0 error:&error]; if (error) { NSLog(@"json generation failed: %@", error); [self callCompletionBlockWithObject:nil status:0 error:[NSError errorWithDomain:@"com.plsys.semaphore.CometAPI" code:1003 userInfo:nil]]; return; } [self handleRequest:request completion:completion]; }
  • 20. Controller Implementation • SkuController • subclass of UITableViewController
  • 21. SkuController - data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [skus count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSDictionary *sku = [skus objectAtIndex:indexPath.row]; static NSString *CellIdentifier = @"SkuCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; } // Configure the cell... cell.textLabel.text = [[sku valueForKey:@"productName"] pl_stringByStrippingHTML]; cell.detailTextLabel.text = [sku valueForKey:@"skuNum"]; id image = [images objectAtIndex:indexPath.row]; if ([image isKindOfClass:[UIImage class]]) { cell.imageView.image = image; } return cell; }
  • 22. SkuController - tv delegate - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { NSDictionary *sku = [skus objectAtIndex:indexPath.row]; NSString *skuNum = [[sku valueForKey:@"skuNum"] copy]; NSLog(@"tapped: %@", skuNum); SkuDetail *view = [[SkuDetail alloc] initWithStyle:UITableViewStylePlain]; view.sku = sku; view.image = [images objectAtIndex:indexPath.row]; [self.navigationController pushViewController:view animated:YES]; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [self tableView:tableView accessoryButtonTappedForRowWithIndexPath:indexPath]; } - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row == ((batch + 1)*25)-1) { // time to fetch more self.batch = ++batch; NSMutableDictionary *batchParameters = [parameters mutableCopy]; if (!batchParameters) batchParameters = [NSMutableDictionary dictionary]; [batchParameters setObject:[NSNumber numberWithInt:batch] forKey:@"batch"]; NSLog(@"batchParameters %@", batchParameters); [CometAPI get:query parameters:batchParameters completionBlock:^(PLRestful *api, id object, NSInteger status, NSError *error) { if (error) [self handleError:error]; else { [self didAddSkus:object]; } }]; } }
  • 23. Other iOS Topics • Human Interface Guidelines • Buttons - 44x44 • Gestures • Controllers - mail, movie, picker • Other UIControls - switch, slider, page control • iOS 7
  • 24. Code Example • SOE Status • http://github.com/pauldlynch/SOEStatus • older version, will update soon