2: Responsive Social Gaming with RESTful Web Services in Objective-C

Creator QR Code in Objective-C 2: Responsive Social Gaming with RESTful Web Services

CHAPTER 2: Responsive Social Gaming with RESTful Web Services
QR Code ISO/IEC18004 Printer In Objective-C
Using Barcode printer for iPhone Control to generate, create Quick Response Code image in iPhone applications.
www.OnBarcode.com
EAN13 Generator In Objective-C
Using Barcode encoder for iPhone Control to generate, create EAN13 image in iPhone applications.
www.OnBarcode.com
// changes to ViewHighScoresAppDelegate.h #import <UIKit/UIKit.h> @class RootViewController; @interface ViewHighScoresAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; UINavigationController *navigationController; NSArray *highScores; RootViewController *rootViewController; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet UINavigationController *navigationController; @property (nonatomic, retain) NSArray *highScores; @property (nonatomic, retain) IBOutlet RootViewController *rootViewController; - (void)getHighScores; @end // changes to ViewHighScoresAppDelegate.m #import "ViewHighScoresAppDelegate.h" #import "RootViewController.h" #import "ObjectiveResourceConfig.h" @implementation ViewHighScoresAppDelegate @synthesize window; @synthesize navigationController; @synthesize highScores; @synthesize rootViewController; #define HIGH_SCORES_URL @"http://localhost:3000/" - (void)applicationDidFinishLaunching:(UIApplication *)application { // Configure and show the window [window addSubview:[navigationController view]]; [window makeKeyAndVisible];
Barcode Encoder In Objective-C
Using Barcode generator for iPhone Control to generate, create Barcode image in iPhone applications.
www.OnBarcode.com
Code 39 Maker In Objective-C
Using Barcode creator for iPhone Control to generate, create Code 39 Full ASCII image in iPhone applications.
www.OnBarcode.com
CHAPTER 2: Responsive Social Gaming with RESTful Web Services
UPC-A Supplement 5 Generation In Objective-C
Using Barcode creator for iPhone Control to generate, create UPC-A image in iPhone applications.
www.OnBarcode.com
Barcode Generator In Objective-C
Using Barcode creator for iPhone Control to generate, create Barcode image in iPhone applications.
www.OnBarcode.com
[ObjectiveResourceConfig setSite: HIGH_SCORES_URL]; [self getHighScores]; } - (void)applicationWillTerminate:(UIApplication *)application { // Save data if appropriate } - (void)dealloc { [navigationController release]; [window release]; [super dealloc]; } #pragma mark web service connection methods - (void)getHighScores { highScores = [HighScore getTop100Scores]; } // you can delete all the URL loading and XML parsing code // you won't need it! @end // changes to RootViewController.m // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; } // Set up the cell... ViewHighScoresAppDelegate *appDelegate = (ViewHighScoresAppDelegate *)[[UIApplication sharedApplication] delegate]; HighScore *highScore = [[appDelegate highScores] objectAtIndex:indexPath.row];
USS Code 128 Creator In Objective-C
Using Barcode maker for iPhone Control to generate, create ANSI/AIM Code 128 image in iPhone applications.
www.OnBarcode.com
Making European Article Number 8 In Objective-C
Using Barcode generator for iPhone Control to generate, create EAN8 image in iPhone applications.
www.OnBarcode.com
CHAPTER 2: Responsive Social Gaming with RESTful Web Services
Drawing Denso QR Bar Code In VS .NET
Using Barcode encoder for .NET framework Control to generate, create QR-Code image in .NET applications.
www.OnBarcode.com
Make QR Code 2d Barcode In Objective-C
Using Barcode creator for iPhone Control to generate, create QR Code JIS X 0510 image in iPhone applications.
www.OnBarcode.com
cell.text = [NSString stringWithFormat:@"%@ - %@", highScore.full_name, highScore.score]; return cell; }
Data Matrix Creator In .NET
Using Barcode printer for ASP.NET Control to generate, create Data Matrix image in ASP.NET applications.
www.OnBarcode.com
Generate ECC200 In Objective-C
Using Barcode creation for iPad Control to generate, create Data Matrix ECC200 image in iPad applications.
www.OnBarcode.com
As you can see, the code to use ObjectiveResource is substantially simpler and shorter than the version that uses URL loading and XML parsing.
Scanning Code 128 In .NET Framework
Using Barcode recognizer for VS .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
Universal Product Code Version A Generator In None
Using Barcode printer for Office Word Control to generate, create GS1 - 12 image in Word applications.
www.OnBarcode.com
Submitting High Scores with ObjectiveResource
Drawing EAN13 In Visual C#.NET
Using Barcode encoder for Visual Studio .NET Control to generate, create European Article Number 13 image in .NET framework applications.
www.OnBarcode.com
Create Data Matrix In Visual Studio .NET
Using Barcode maker for Reporting Service Control to generate, create ECC200 image in Reporting Service applications.
www.OnBarcode.com
Listing 2-24 shows how to submit a high-score record to the web service.
Generate UCC - 12 In Java
Using Barcode creation for Java Control to generate, create Universal Product Code version A image in Java applications.
www.OnBarcode.com
Printing GTIN - 13 In Java
Using Barcode creation for Android Control to generate, create GTIN - 13 image in Android applications.
www.OnBarcode.com
Listing 2-24. Using ObjectiveResource to Submit a High Score
Paint ANSI/AIM Code 128 In Java
Using Barcode generation for Java Control to generate, create USS Code 128 image in Java applications.
www.OnBarcode.com
Reading Data Matrix ECC200 In C#.NET
Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
HighScore newScore = [[[HighScore alloc] init] autorelease]; newScore.full_name = "Bobby"; newScore.score = 10002; [newScore saveRemote];
And that is really it! If you ve used Hibernate on Java or NHibernate on .NET, you ll find that using ObjectiveResource is similar. The difference is that there is no mindless XML configuration, and you re dealing with a web service, rather than a database. ObjectiveResource simplifies communications with RESTful web services significantly. All the URL loading and XML parsing take place behind the scenes. Your objects will inherit code from the ObjectiveResource category to make simple methods calls for creating, retrieving, updating, and deleting records on your RESTful web services.
Summary
This chapter walked you through how to use URL loading and XML parsing to create a highscore server. It was very code-heavy, but to be honest, at the time of this writing, very few resources, online or in book form, deal with the subject in this much detail. And this detail is important to get social networking implemented the right way for your iPhone games. When push comes to shove, and you re trying to get a social networking feature built into your app, are you going to be glad I dug in deep, or would you rather I had stuck to pleasing platitudes, all mom and apple pie, about the wonderful dream of social networking built into native iPhone games Yeah, that s what I thought. In the end, I hope I was successful in getting you excited about the possibility of adding social networking features directly into your game. Perhaps I ve made you think about spending a bit more development time doing more than just a high-score server. Wouldn t it be cool to give players at least a My highest score widget It may help promote your game!
CHAPTER 2: Responsive Social Gaming with RESTful Web Services
Letting your users share their gaming experience with others can help grow a community around your games, which can lead to strong sales. But, for me, it all goes back to being social, playing in groups, with friends and family hovering around the TV and having a good time. With the ubiquitous connectivity in the iPhone and social networking, we may be able to bring some of those good times back to gaming.
Copyright © OnBarcode.com . All rights reserved.