Permalink
Browse files

Updated GameKit to include non-peerpicker demonstration outside the b…

…ook examples.
  • Loading branch information...
1 parent 4265e5a commit e351ee9fbee646b68cd8f884fe3c84c5cf65b65b Erica Sadun committed Dec 1, 2009
View
2 C07-Images/07-Sending Pictures By Email/ModalHUD.h
@@ -8,5 +8,5 @@
@interface ModalHUD : NSObject
+ (void) showHUD:(id)formatstring,...;
-+ (void) dismiss;
++ (BOOL) dismiss;
@end
View
16 C07-Images/07-Sending Pictures By Email/ModalHUD.m
@@ -9,10 +9,20 @@
#define MODAL_HUD_UNIQUE_ID 314159265
@implementation ModalHUD
-+ (void) dismiss
+
+// Thanks to xhan for pointing out potential for dismiss errors when dismiss message sent too soon
+// Dismiss changed to BOOL, offering success feedback
++ (BOOL) dismiss
{
- UIAlertView *av = (UIAlertView *)[[[UIApplication sharedApplication] keyWindow] viewWithTag:MODAL_HUD_UNIQUE_ID];
- [av dismissWithClickedButtonIndex:0 animated:YES];
+ UIAlertView *av;
+
+ if (av = (UIAlertView *)[[[UIApplication sharedApplication] keyWindow] viewWithTag:MODAL_HUD_UNIQUE_ID])
+ {
+ [av dismissWithClickedButtonIndex:0 animated:YES];
+ return YES;
+ }
+
+ return NO;
}
#pragma mark Activity Indicator HUD Utilities
View
64 C07-Images/07-Sending Pictures By Email/TestBedViewController.xib
@@ -1,11 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.03">
+<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">768</int>
- <string key="IBDocument.SystemVersion">9J61</string>
- <string key="IBDocument.InterfaceBuilderVersion">677</string>
- <string key="IBDocument.AppKitVersion">949.46</string>
- <string key="IBDocument.HIToolboxVersion">353.00</string>
+ <string key="IBDocument.SystemVersion">10C540</string>
+ <string key="IBDocument.InterfaceBuilderVersion">740</string>
+ <string key="IBDocument.AppKitVersion">1038.25</string>
+ <string key="IBDocument.HIToolboxVersion">458.00</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="NS.object.0">62</string>
+ </object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
@@ -15,7 +19,7 @@
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSArray" key="dict.sortedKeys">
+ <object class="NSArray" key="dict.sortedKeys" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
@@ -60,34 +64,32 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
- <object class="NSArray" key="object" id="884947135">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
+ <reference key="object" ref="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="372490531"/>
- <reference key="parent" ref="884947135"/>
- <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="843779117"/>
- <reference key="parent" ref="884947135"/>
+ <reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">8</int>
<reference key="object" ref="423360241"/>
- <reference key="parent" ref="884947135"/>
+ <reference key="parent" ref="0"/>
<string key="objectName">View</string>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMutableArray" key="dict.sortedKeys">
+ <object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.CustomClassName</string>
<string>-2.CustomClassName</string>
@@ -104,19 +106,15 @@
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSArray" key="dict.sortedKeys">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
+ <reference key="dict.sortedKeys" ref="0"/>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSArray" key="dict.sortedKeys">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
+ <reference key="dict.sortedKeys" ref="0"/>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
@@ -125,21 +123,37 @@
<int key="maxID">31</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
- <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.1+">
+ <object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">TestBedViewController</string>
- <string key="superclassName">UIViewController</string>
+ <object class="NSMutableDictionary" key="outlets">
+ <string key="NS.key.0">view</string>
+ <string key="NS.object.0">id</string>
+ </object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBDocumentRelativeSource</string>
- <string key="minorKey">../00SampleCode/TestBedViewController.h</string>
+ <string key="majorKey">IBUserSource</string>
+ <string key="minorKey"/>
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
+ <integer value="768" key="NS.object.0"/>
+ </object>
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
+ <integer value="512" key="NS.object.0"/>
+ </object>
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
+ <integer value="3000" key="NS.object.0"/>
+ </object>
+ <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<string key="IBDocument.LastKnownRelativeProjectPath">HelloWorld.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
- <string key="IBCocoaTouchPluginVersion">3.0</string>
+ <string key="IBCocoaTouchPluginVersion">3.1</string>
</data>
</archive>
View
8 C07-Images/07-Sending Pictures By Email/main.m
@@ -22,6 +22,12 @@ - (void)mailComposeController:(MFMailComposeViewController*)controller didFinish
[self dismissModalViewControllerAnimated:YES];
}
+- (void) dismissHUD
+{
+ if (![ModalHUD dismiss])
+ [self performSelector:@selector(dismissHUD) withObject:nil afterDelay:0.2f];
+}
+
- (void) emailImage: (UIImage *) image
{
if ([MFMailComposeViewController canSendMail])
@@ -33,7 +39,7 @@ - (void) emailImage: (UIImage *) image
[mcvc setMessageBody:body isHTML:YES];
[mcvc addAttachmentData:UIImageJPEGRepresentation(image, 1.0f) mimeType:@"image/jpeg" fileName:@"pickerimage.jpg"];
[self presentModalViewController:mcvc animated:YES];
- [ModalHUD dismiss];
+ [self dismissHUD];
}
}
View
2 C07-Images/12-Bitmaps/ModalHUD.h
@@ -8,5 +8,5 @@
@interface ModalHUD : NSObject
+ (void) showHUD:(id)formatstring,...;
-+ (void) dismiss;
++ (BOOL) dismiss;
@end
View
15 C07-Images/12-Bitmaps/ModalHUD.m
@@ -9,10 +9,19 @@
#define MODAL_HUD_UNIQUE_ID 314159265
@implementation ModalHUD
-+ (void) dismiss
+// Thanks to xhan for pointing out potential for dismiss errors when dismiss message sent too soon
+// Dismiss changed to BOOL, offering success feedback
++ (BOOL) dismiss
{
- UIAlertView *av = (UIAlertView *)[[[UIApplication sharedApplication] keyWindow] viewWithTag:MODAL_HUD_UNIQUE_ID];
- [av dismissWithClickedButtonIndex:0 animated:YES];
+ UIAlertView *av;
+
+ if (av = (UIAlertView *)[[[UIApplication sharedApplication] keyWindow] viewWithTag:MODAL_HUD_UNIQUE_ID])
+ {
+ [av dismissWithClickedButtonIndex:0 animated:YES];
+ return YES;
+ }
+
+ return NO;
}
#pragma mark Activity Indicator HUD Utilities
View
11 C07-Images/12-Bitmaps/main.m
@@ -31,11 +31,17 @@ - (void) swap
if ([(UIImageView *)self.view image] == self.original) SETIMAGE(self.processed) else SETIMAGE(self.original);
}
+- (void) dismissHUD
+{
+ if (![ModalHUD dismiss])
+ [self performSelector:@selector(dismissHUD) withObject:nil afterDelay:0.2f];
+}
+
- (void) finish
{
SETIMAGE(self.processed);
self.navigationItem.leftBarButtonItem = BARBUTTON(@"Swap", @selector(swap));
- [ModalHUD dismiss];
+ [self dismissHUD];
}
- (void) process
@@ -54,11 +60,10 @@ - (void) process
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
- [ModalHUD showHUD:@"Processing\nPlease wait."];
self.original = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
[self dismissModalViewControllerAnimated:YES];
[picker release];
-
+ [ModalHUD performSelector:@selector(showHUD:) withObject:@"Processing\nPlease wait." afterDelay:0.01f];
[NSThread detachNewThreadSelector:@selector(process) toTarget:self withObject:nil];
}
View
BIN C12-GameKit/01b-CustomGUI/Default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
41 C12-GameKit/01b-CustomGUI/GameKitHelper.h
@@ -0,0 +1,41 @@
+/*
+ Erica Sadun, http://ericasadun.com
+ iPhone Developer's Cookbook, 3.0 Edition
+ BSD License, Use at your own risk
+ */
+
+#import <UIKit/UIKit.h>
+#import <GameKit/GameKit.h>
+
+/*
+
+ This version of GameKit helper is a little extra to demonstrate how to avoid
+ using the built-in peer picker. It's pretty bare bones but hopefully the idea will
+ get across.
+
+ */
+
+@protocol GameKitHelperDataDelegate <NSObject>
+@optional
+-(void) connectionEstablished;
+-(void) connectionLost;
+-(void) sentData: (NSString *) errorMessage;
+-(void) receivedData: (NSData *) data;
+@end
+
+@interface GameKitHelper : NSObject <GKPeerPickerControllerDelegate, GKSessionDelegate>
+{
+ NSString *sessionID;
+ GKSession *mySession;
+ int connectStage;
+ IBOutlet UIViewController <GameKitHelperDataDelegate> *viewController;
+}
+
+@property (retain) NSString *sessionID;
+@property (retain) GKSession *mySession;
+@property (retain) UIViewController *viewController;
+
+- (void) disconnect;
+- (void) sendData: (NSData *) data;
+- (BOOL) isConnected;
+@end
View
214 C12-GameKit/01b-CustomGUI/GameKitHelper.m
@@ -0,0 +1,214 @@
+
+/*
+ Erica Sadun, http://ericasadun.com
+ iPhone Developer's Cookbook, 3.0 Edition
+ BSD License, Use at your own risk
+ */
+
+#import "GameKitHelper.h"
+
+#define TIME_OUT_TIME 60.0f
+
+/*
+
+ Peer Tracker helps ignored already-identified peers, skipping them while trying to
+ establish a connection. Apple's Peer Picker doesn't do this, hence the ghost
+ connections that appear on the gk stack.
+
+ */
+@interface PeerTracker : NSObject
++ (BOOL) vetPeerID: (NSString *) anID;
+@end
+
+@implementation PeerTracker
++ (BOOL) vetPeerID: (NSString *) anID
+{
+ NSDictionary *storedPeers = [[NSUserDefaults standardUserDefaults] objectForKey:@"Peer Dictionary"];
+ NSMutableDictionary *knownPeers = storedPeers ? [NSMutableDictionary dictionaryWithDictionary:storedPeers] : [NSMutableDictionary dictionary];
+
+ // Is the peer found? Will vet if not found
+ BOOL result = [knownPeers objectForKey:anID] != nil;
+
+ // Clean up the dictionary
+ for (NSString *key in [knownPeers allKeys])
+ {
+ NSDate *date = [knownPeers objectForKey:key];
+ if (ABS([[NSDate date] timeIntervalSinceDate:date]) > 60 * 60) // over 1 hour
+ [knownPeers removeObjectForKey:key];
+ }
+
+ // Register the peer
+ [knownPeers setObject:[NSDate date] forKey:anID];
+
+ [[NSUserDefaults standardUserDefaults] setObject:knownPeers forKey:@"Peer Dictionary"];
+ [[NSUserDefaults standardUserDefaults] synchronize];
+
+ return result;
+}
+@end
+
+@implementation GameKitHelper
+@synthesize sessionID;
+@synthesize mySession;
+@synthesize viewController;
+
+#define DO_DATA_CALLBACK(X, Y) if (viewController && [viewController respondsToSelector:@selector(X)]) [viewController performSelector:@selector(X) withObject:Y];
+#define BARBUTTON(TITLE, SELECTOR) [[[UIBarButtonItem alloc] initWithTitle:TITLE style:UIBarButtonItemStylePlain target:self action:SELECTOR] autorelease]
+
+- (BOOL) isConnected
+{
+ return (connectStage == 2);
+}
+
+- (void) disconnect
+{
+ // Manually disconnect from all current peers
+ [mySession disconnectFromAllPeers];
+ [mySession setAvailable:NO];
+ connectStage = 0;
+ self.mySession = nil;
+
+ // Update the GUI
+ viewController.navigationItem.rightBarButtonItem = BARBUTTON(@"Connect", @selector(connect));
+}
+
+- (void) connect
+{
+ if (mySession) return; // already trying to connect
+
+ // Update the GUI
+ viewController.navigationItem.rightBarButtonItem = BARBUTTON(@"Cancel...", @selector(disconnect));
+
+ NSLog(@"Starting up...");
+ if (!self.sessionID) self.sessionID = @"Sample Session";
+ self.mySession = [[GKSession alloc] initWithSessionID:self.sessionID displayName:nil sessionMode:GKSessionModePeer];
+
+ // Allow session to become available
+ [mySession release];
+ mySession.delegate = self;
+ [mySession setAvailable:YES];
+ connectStage = 0;
+}
+
+- (void)session:(GKSession *)session didFailWithError:(NSError *)error
+{
+ NSLog(@"End of the world as we know it...");
+ NSLog(@"Session failed with error: %@", [error localizedDescription]);
+ [self disconnect];
+}
+
+- (void) connectAgain: (NSString *) peerID
+{
+ // Don't connect again if we're already connected, otherwise try again
+ if (connectStage == 2) return;
+ [mySession connectToPeer:peerID withTimeout:TIME_OUT_TIME];
+}
+
+- (void)session:(GKSession *)session connectionWithPeerFailed:(NSString *)peerID withError:(NSError *)error
+{
+ // Don't connect again if we're already connected, otherwise try again
+ if (connectStage == 2) return;
+ NSLog(@"Connection failed with peer %@ with error: %@", [session displayNameForPeer:peerID], [error localizedDescription]);
+ [session setAvailable:YES];
+ [self performSelector:@selector(connectAgain:) withObject:peerID afterDelay:2.0f];
+}
+
+- (void)session:(GKSession *)session didReceiveConnectionRequestFromPeer:(NSString *)peerID
+{
+ // Peer is trying to connect. Accept that connection.
+ NSLog(@"Received connection request from peer %@\n", [session displayNameForPeer:peerID]);
+ NSLog(@"Attempting to connect...");
+
+ NSError *error;
+ BOOL yorn = [session acceptConnectionFromPeer:peerID error:&error];
+ if (!yorn)
+ NSLog(@"Attempt %d: Error accepting connection from %@: %@", [session displayNameForPeer:peerID], [error localizedDescription]);
+ else
+ {
+ NSLog(@"Accepted connection from %@", [session displayNameForPeer:peerID]);
+ [mySession setDataReceiveHandler:self withContext:nil];
+ connectStage = 2;
+ DO_DATA_CALLBACK(connectionEstablished, nil);
+
+ if (session != mySession) self.mySession = session;
+
+ // Update the GUI
+ viewController.navigationItem.rightBarButtonItem = BARBUTTON(@"Disconnect", @selector(disconnect));
+ }
+}
+
+- (void)session:(GKSession *)session peer:(NSString *)peerID didChangeState:(GKPeerConnectionState)state
+{
+ switch (state)
+ {
+ case GKPeerStateAvailable:
+ {
+ if ([PeerTracker vetPeerID:peerID])
+ {
+ NSLog(@"Recognized available peer (%@). Ignoring it.", [session displayNameForPeer:peerID]);
+ return;
+ }
+
+ if (connectStage == 0)
+ {
+ NSLog(@"Peer %@ is available. Attempting to connect.", [session displayNameForPeer:peerID]);
+ connectStage = 1;
+ [session connectToPeer:peerID withTimeout:TIME_OUT_TIME];
+ }
+ break;
+ }
+ case GKPeerStateUnavailable:
+ NSLog(@"Peer %@ is no longer available", [session displayNameForPeer:peerID]);
+ break;
+ case GKPeerStateConnected:
+ {
+ NSLog(@"Peer %@ has connected", [session displayNameForPeer:peerID]);
+ if (session != mySession)
+ self.mySession = session;
+
+ [mySession setDataReceiveHandler:self withContext:nil];
+ connectStage = 2;
+ DO_DATA_CALLBACK(connectionEstablished, nil);
+
+ // Update the GUI
+ viewController.navigationItem.rightBarButtonItem = BARBUTTON(@"Disconnect", @selector(disconnect));
+ break;
+ }
+ case GKPeerStateDisconnected:
+ {
+ DO_DATA_CALLBACK(connectionLost, nil);
+ NSLog(@"Peer %@ is disconnected", [session displayNameForPeer:peerID]);
+
+ if (connectStage == 2)
+ {
+ // Update the GUI
+ viewController.navigationItem.rightBarButtonItem = BARBUTTON(@"Connect", @selector(connect));
+ connectStage = 0;
+ }
+
+ break;
+ }
+ case GKPeerStateConnecting:
+ NSLog(@"Peer %@ is connecting...", [session displayNameForPeer:peerID]);
+ connectStage = 1;
+ break;
+ default:
+ break;
+ }
+}
+
+#pragma mark Data Sharing
+- (void) sendData: (NSData *) data
+{
+ NSError *error;
+ BOOL didSend = [mySession sendDataToAllPeers:data withDataMode:GKSendDataReliable error:&error];
+ if (!didSend)
+ NSLog(@"Error sending data to peers: %@", [error localizedDescription]);
+ DO_DATA_CALLBACK(sentData:, (didSend ? nil : [error localizedDescription]));
+}
+
+- (void) receiveData:(NSData *)data fromPeer:(NSString *)peer inSession: (GKSession *)session context:(void *)context
+{
+ DO_DATA_CALLBACK(receivedData:, data);
+}
+@end
View
247 C12-GameKit/01b-CustomGUI/HelloWorld.xcodeproj/project.pbxproj
@@ -0,0 +1,247 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 45;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 1D3623EC0D0F72F000981E51 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D3623EB0D0F72F000981E51 /* CoreGraphics.framework */; };
+ 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; };
+ 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
+ 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
+ 8E3A1F090FAA199F009B0518 /* cover320x416.png in Resources */ = {isa = PBXBuildFile; fileRef = 8E3A1F080FAA199F009B0518 /* cover320x416.png */; };
+ 8E4156E90FA4EE0E0006D27C /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 8E4156E70FA4EE0E0006D27C /* Default.png */; };
+ 8E4156EA0FA4EE0E0006D27C /* icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 8E4156E80FA4EE0E0006D27C /* icon.png */; };
+ 8E460D8E1018E3E0008A8B1D /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E460D8D1018E3E0008A8B1D /* GameKit.framework */; };
+ 8E785FCB0FCDB853006EA81F /* TestBedViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8E785FCA0FCDB853006EA81F /* TestBedViewController.xib */; };
+ 8EA4078810C4B94300792502 /* GameKitHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EA4078710C4B94300792502 /* GameKitHelper.m */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ 1D3623EB0D0F72F000981E51 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+ 1D6058910D05DD3D006BFB54 /* HelloWorld.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloWorld.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
+ 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ 32CA4F630368D1EE00C91783 /* HelloWorld_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelloWorld_Prefix.pch; sourceTree = "<group>"; };
+ 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ 8E3A1F080FAA199F009B0518 /* cover320x416.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cover320x416.png; sourceTree = "<group>"; };
+ 8E4156E70FA4EE0E0006D27C /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = "<group>"; };
+ 8E4156E80FA4EE0E0006D27C /* icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon.png; sourceTree = "<group>"; };
+ 8E460D8D1018E3E0008A8B1D /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = System/Library/Frameworks/GameKit.framework; sourceTree = SDKROOT; };
+ 8E785FCA0FCDB853006EA81F /* TestBedViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TestBedViewController.xib; sourceTree = "<group>"; };
+ 8EA4078610C4B94300792502 /* GameKitHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameKitHelper.h; sourceTree = "<group>"; };
+ 8EA4078710C4B94300792502 /* GameKitHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameKitHelper.m; sourceTree = "<group>"; };
+ 8EA407C010C4BBDA00792502 /* TestBedViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestBedViewController.h; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 1D60588F0D05DD3D006BFB54 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */,
+ 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */,
+ 1D3623EC0D0F72F000981E51 /* CoreGraphics.framework in Frameworks */,
+ 8E460D8E1018E3E0008A8B1D /* GameKit.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 19C28FACFE9D520D11CA2CBB /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 1D6058910D05DD3D006BFB54 /* HelloWorld.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
+ isa = PBXGroup;
+ children = (
+ 8EA407C010C4BBDA00792502 /* TestBedViewController.h */,
+ 29B97316FDCFA39411CA2CEA /* main.m */,
+ 8E785FCA0FCDB853006EA81F /* TestBedViewController.xib */,
+ 8EA4078610C4B94300792502 /* GameKitHelper.h */,
+ 8EA4078710C4B94300792502 /* GameKitHelper.m */,
+ 8EB688610FA64AD100489E4B /* Support */,
+ 29B97323FDCFA39411CA2CEA /* Frameworks */,
+ 19C28FACFE9D520D11CA2CBB /* Products */,
+ );
+ name = CustomTemplate;
+ sourceTree = "<group>";
+ };
+ 29B97323FDCFA39411CA2CEA /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 8E460D8D1018E3E0008A8B1D /* GameKit.framework */,
+ 1D3623EB0D0F72F000981E51 /* CoreGraphics.framework */,
+ 1D30AB110D05D00D00671497 /* Foundation.framework */,
+ 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ 8EB688610FA64AD100489E4B /* Support */ = {
+ isa = PBXGroup;
+ children = (
+ 8E3A1F080FAA199F009B0518 /* cover320x416.png */,
+ 32CA4F630368D1EE00C91783 /* HelloWorld_Prefix.pch */,
+ 8D1107310486CEB800E47090 /* Info.plist */,
+ 8E4156E80FA4EE0E0006D27C /* icon.png */,
+ 8E4156E70FA4EE0E0006D27C /* Default.png */,
+ );
+ name = Support;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 1D6058900D05DD3D006BFB54 /* HelloWorld */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HelloWorld" */;
+ buildPhases = (
+ 1D60588D0D05DD3D006BFB54 /* Resources */,
+ 1D60588E0D05DD3D006BFB54 /* Sources */,
+ 1D60588F0D05DD3D006BFB54 /* Frameworks */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = HelloWorld;
+ productName = HelloWorld;
+ productReference = 1D6058910D05DD3D006BFB54 /* HelloWorld.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 29B97313FDCFA39411CA2CEA /* Project object */ = {
+ isa = PBXProject;
+ buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloWorld" */;
+ compatibilityVersion = "Xcode 3.1";
+ hasScannedForEncodings = 1;
+ mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 1D6058900D05DD3D006BFB54 /* HelloWorld */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 1D60588D0D05DD3D006BFB54 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 8E4156E90FA4EE0E0006D27C /* Default.png in Resources */,
+ 8E4156EA0FA4EE0E0006D27C /* icon.png in Resources */,
+ 8E3A1F090FAA199F009B0518 /* cover320x416.png in Resources */,
+ 8E785FCB0FCDB853006EA81F /* TestBedViewController.xib in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 1D60588E0D05DD3D006BFB54 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 1D60589B0D05DD56006BFB54 /* main.m in Sources */,
+ 8EA4078810C4B94300792502 /* GameKitHelper.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ 1D6058940D05DD3E006BFB54 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Erica Sadun";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = HelloWorld_Prefix.pch;
+ INFOPLIST_FILE = Info.plist;
+ PREBINDING = NO;
+ PRODUCT_NAME = HelloWorld;
+ };
+ name = Debug;
+ };
+ 1D6058950D05DD3E006BFB54 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ COPY_PHASE_STRIP = YES;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ GCC_ENABLE_FIX_AND_CONTINUE = NO;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = HelloWorld_Prefix.pch;
+ INFOPLIST_FILE = Info.plist;
+ PREBINDING = NO;
+ PRODUCT_NAME = HelloWorld;
+ WRAPPER_EXTENSION = app;
+ };
+ name = Release;
+ };
+ C01FCF4F08A954540054247B /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ CODE_SIGN_IDENTITY = "Erica Sadun";
+ "CODE_SIGN_IDENTITY[sdk=iphonesimulator*]" = "iPhone Developer";
+ GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ PREBINDING = NO;
+ PRODUCT_NAME = "Oh Hello";
+ SDKROOT = iphoneos2.0;
+ };
+ name = Debug;
+ };
+ C01FCF5008A954540054247B /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ PREBINDING = NO;
+ SDKROOT = iphoneos2.0;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HelloWorld" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1D6058940D05DD3E006BFB54 /* Debug */,
+ 1D6058950D05DD3E006BFB54 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloWorld" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ C01FCF4F08A954540054247B /* Debug */,
+ C01FCF5008A954540054247B /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
+}
View
8 C12-GameKit/01b-CustomGUI/HelloWorld_Prefix.pch
@@ -0,0 +1,8 @@
+//
+// Prefix header for all source files of the 'HelloWorld' target in the 'HelloWorld' project
+//
+
+#ifdef __OBJC__
+ #import <Foundation/Foundation.h>
+ #import <UIKit/UIKit.h>
+#endif
View
26 C12-GameKit/01b-CustomGUI/Info.plist
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>com.sadun.${EXECUTABLE_NAME}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+</dict>
+</plist>
View
18 C12-GameKit/01b-CustomGUI/TestBedViewController.h
@@ -0,0 +1,18 @@
+//
+// TestBedViewController.h
+// HelloWorld
+//
+// Created by Erica Sadun on 11/30/09.
+// Copyright 2009 Up To No Good, Inc.. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "GameKitHelper.h"
+
+@interface TestBedViewController : UIViewController <GameKitHelperDataDelegate, UITextViewDelegate>
+{
+ IBOutlet UITextView *sendView;
+ IBOutlet UITextView *receiveView;
+ IBOutlet GameKitHelper *helper;
+}
+@end
View
359 C12-GameKit/01b-CustomGUI/TestBedViewController.xib
@@ -0,0 +1,359 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
+ <data>
+ <int key="IBDocument.SystemTarget">768</int>
+ <string key="IBDocument.SystemVersion">10C540</string>
+ <string key="IBDocument.InterfaceBuilderVersion">740</string>
+ <string key="IBDocument.AppKitVersion">1038.25</string>
+ <string key="IBDocument.HIToolboxVersion">458.00</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="NS.object.0">62</string>
+ </object>
+ <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <integer value="32"/>
+ </object>
+ <object class="NSArray" key="IBDocument.PluginDependencies">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ </object>
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys" id="0">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBProxyObject" id="372490531">
+ <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
+ </object>
+ <object class="IBProxyObject" id="843779117">
+ <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
+ </object>
+ <object class="IBUIView" id="440620744">
+ <reference key="NSNextResponder"/>
+ <int key="NSvFlags">292</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBUIImageView" id="1064941195">
+ <reference key="NSNextResponder" ref="440620744"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrameSize">{320, 416}</string>
+ <reference key="NSSuperview" ref="440620744"/>
+ <bool key="IBUIOpaque">NO</bool>
+ <bool key="IBUIClipsSubviews">YES</bool>
+ <int key="IBUIContentMode">4</int>
+ <bool key="IBUIMultipleTouchEnabled">YES</bool>
+ <object class="NSCustomResource" key="IBUIImage">
+ <string key="NSClassName">NSImage</string>
+ <string key="NSResourceName">cover320x416.png</string>
+ </object>
+ </object>
+ <object class="IBUITextView" id="395446891">
+ <reference key="NSNextResponder" ref="440620744"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{23, 97}, {274, 75}}</string>
+ <reference key="NSSuperview" ref="440620744"/>
+ <object class="NSColor" key="IBUIBackgroundColor">
+ <int key="NSColorSpace">2</int>
+ <bytes key="NSRGB">MC4xNjA3ODQzMiAwLjEwMTk2MDc5IDAuNTYwNzg0MzQAA</bytes>
+ </object>
+ <bool key="IBUIOpaque">NO</bool>
+ <bool key="IBUIClipsSubviews">YES</bool>
+ <bool key="IBUIMultipleTouchEnabled">YES</bool>
+ <int key="IBUITag">102</int>
+ <bool key="IBUIShowsHorizontalScrollIndicator">NO</bool>
+ <bool key="IBUIDelaysContentTouches">NO</bool>
+ <bool key="IBUICanCancelContentTouches">NO</bool>
+ <bool key="IBUIBouncesZoom">NO</bool>
+ <bool key="IBUIEditable">NO</bool>
+ <string key="IBUIText"/>
+ <object class="NSColor" key="IBUITextColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MQA</bytes>
+ </object>
+ <object class="NSFont" key="IBUIFont" id="70252300">
+ <string key="NSName">Helvetica-Bold</string>
+ <double key="NSSize">17</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ <object class="IBUITextInputTraits" key="IBUITextInputTraits">
+ <int key="IBUIAutocapitalizationType">2</int>
+ </object>
+ <int key="IBUIDataDetectorTypes">3</int>
+ </object>
+ <object class="IBUITextView" id="399574276">
+ <reference key="NSNextResponder" ref="440620744"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{23, 11}, {274, 78}}</string>
+ <reference key="NSSuperview" ref="440620744"/>
+ <object class="NSColor" key="IBUIBackgroundColor">
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MC43ODA2MTIyMyAwLjc4MDYxMjIzIDAuNzgwNjEyMjMAA</bytes>
+ </object>
+ <bool key="IBUIOpaque">NO</bool>
+ <bool key="IBUIClipsSubviews">YES</bool>
+ <bool key="IBUIMultipleTouchEnabled">YES</bool>
+ <int key="IBUITag">101</int>
+ <bool key="IBUIShowsHorizontalScrollIndicator">NO</bool>
+ <bool key="IBUIDelaysContentTouches">NO</bool>
+ <bool key="IBUICanCancelContentTouches">NO</bool>
+ <bool key="IBUIBouncesZoom">NO</bool>
+ <string key="IBUIText"/>
+ <object class="NSColor" key="IBUITextColor">
+ <int key="NSColorSpace">2</int>
+ <bytes key="NSRGB">MC4xNjA3ODQzMiAwLjEwMTk2MDc5IDAuNTYwNzg0MzQAA</bytes>
+ </object>
+ <reference key="IBUIFont" ref="70252300"/>
+ <object class="IBUITextInputTraits" key="IBUITextInputTraits">
+ <int key="IBUIAutocapitalizationType">2</int>
+ <int key="IBUIAutocorrectionType">1</int>
+ <int key="IBUIReturnKeyType">7</int>
+ </object>
+ </object>
+ </object>
+ <string key="NSFrameSize">{320, 416}</string>
+ <reference key="NSSuperview"/>
+ <object class="NSColor" key="IBUIBackgroundColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MQA</bytes>
+ <object class="NSColorSpace" key="NSCustomColorSpace">
+ <int key="NSID">2</int>
+ </object>
+ </object>
+ <bool key="IBUIClearsContextBeforeDrawing">NO</bool>
+ <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
+ <object class="IBUISimulatedNavigationBarMetrics" key="IBUISimulatedTopBarMetrics">
+ <bool key="IBUIPrompted">NO</bool>
+ </object>
+ </object>
+ <object class="IBUICustomObject" id="940253566"/>
+ </object>
+ <object class="IBObjectContainer" key="IBDocument.Objects">
+ <object class="NSMutableArray" key="connectionRecords">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">view</string>
+ <reference key="source" ref="372490531"/>
+ <reference key="destination" ref="440620744"/>
+ </object>
+ <int key="connectionID">33</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">sendView</string>
+ <reference key="source" ref="372490531"/>
+ <reference key="destination" ref="399574276"/>
+ </object>
+ <int key="connectionID">39</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">receiveView</string>
+ <reference key="source" ref="372490531"/>
+ <reference key="destination" ref="395446891"/>
+ </object>
+ <int key="connectionID">40</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="399574276"/>
+ <reference key="destination" ref="372490531"/>
+ </object>
+ <int key="connectionID">41</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">helper</string>
+ <reference key="source" ref="372490531"/>
+ <reference key="destination" ref="940253566"/>
+ </object>
+ <int key="connectionID">44</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">viewController</string>
+ <reference key="source" ref="940253566"/>
+ <reference key="destination" ref="372490531"/>
+ </object>
+ <int key="connectionID">45</int>
+ </object>
+ </object>
+ <object class="IBMutableOrderedSet" key="objectRecords">
+ <object class="NSArray" key="orderedObjects">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBObjectRecord">
+ <int key="objectID">0</int>
+ <reference key="object" ref="0"/>
+ <reference key="children" ref="1000"/>
+ <nil key="parent"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-1</int>
+ <reference key="object" ref="372490531"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">File's Owner</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-2</int>
+ <reference key="object" ref="843779117"/>
+ <reference key="parent" ref="0"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">32</int>
+ <reference key="object" ref="440620744"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="1064941195"/>
+ <reference ref="399574276"/>
+ <reference ref="395446891"/>
+ </object>
+ <reference key="parent" ref="0"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">34</int>
+ <reference key="object" ref="1064941195"/>
+ <reference key="parent" ref="440620744"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">35</int>
+ <reference key="object" ref="395446891"/>
+ <reference key="parent" ref="440620744"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">36</int>
+ <reference key="object" ref="399574276"/>
+ <reference key="parent" ref="440620744"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">43</int>
+ <reference key="object" ref="940253566"/>
+ <reference key="parent" ref="0"/>
+ </object>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="flattenedProperties">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>-1.CustomClassName</string>
+ <string>-2.CustomClassName</string>
+ <string>32.IBEditorWindowLastContentRect</string>
+ <string>32.IBPluginDependency</string>
+ <string>35.IBPluginDependency</string>
+ <string>36.IBPluginDependency</string>
+ <string>43.CustomClassName</string>
+ <string>43.IBPluginDependency</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>TestBedViewController</string>
+ <string>UIResponder</string>
+ <string>{{708, 90}, {320, 480}}</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string>GameKitHelper</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="unlocalizedProperties">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference key="dict.sortedKeys" ref="0"/>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <nil key="activeLocalization"/>
+ <object class="NSMutableDictionary" key="localizations">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference key="dict.sortedKeys" ref="0"/>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <nil key="sourceID"/>
+ <int key="maxID">45</int>
+ </object>
+ <object class="IBClassDescriber" key="IBDocument.Classes">
+ <object class="NSMutableArray" key="referencedPartialClassDescriptions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBPartialClassDescription">
+ <string key="className">GameKitHelper</string>
+ <string key="superclassName">NSObject</string>
+ <object class="NSMutableDictionary" key="actions">
+ <string key="NS.key.0">toggleConnection</string>
+ <string key="NS.object.0">id</string>
+ </object>
+ <object class="NSMutableDictionary" key="outlets">
+ <string key="NS.key.0">viewController</string>
+ <string key="NS.object.0">UIViewController</string>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">GameKitHelper.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">TestBedViewController</string>
+ <string key="superclassName">UIViewController</string>
+ <object class="NSMutableDictionary" key="outlets">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>helper</string>
+ <string>receiveView</string>
+ <string>sendView</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>GameKitHelper</string>
+ <string>UITextView</string>
+ <string>UITextView</string>
+ </object>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">TestBedViewController.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">TestBedViewController</string>
+ <string key="superclassName">UIViewController</string>
+ <object class="NSMutableDictionary" key="outlets">
+ <string key="NS.key.0">view</string>
+ <string key="NS.object.0">UIView</string>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBUserSource</string>
+ <string key="minorKey"/>
+ </object>
+ </object>
+ </object>
+ </object>
+ <int key="IBDocument.localizationMode">0</int>
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
+ <integer value="768" key="NS.object.0"/>
+ </object>
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
+ <integer value="512" key="NS.object.0"/>
+ </object>
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
+ <integer value="3000" key="NS.object.0"/>
+ </object>
+ <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
+ <string key="IBDocument.LastKnownRelativeProjectPath">HelloWorld.xcodeproj</string>
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
+ <string key="IBCocoaTouchPluginVersion">3.1</string>
+ </data>
+</archive>
View
BIN C12-GameKit/01b-CustomGUI/cover320x416.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN C12-GameKit/01b-CustomGUI/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
66 C12-GameKit/01b-CustomGUI/main.m
@@ -0,0 +1,66 @@
+/*
+ Erica Sadun, http://ericasadun.com
+ iPhone Developer's Cookbook, 3.0 Edition
+ BSD License, Use at your own risk
+ */
+
+#import <UIKit/UIKit.h>
+#import "TestBedViewController.h"
+
+#define COOKBOOK_PURPLE_COLOR [UIColor colorWithRed:0.20392f green:0.19607f blue:0.61176f alpha:1.0f]
+#define BARBUTTON(TITLE, SELECTOR) [[[UIBarButtonItem alloc] initWithTitle:TITLE style:UIBarButtonItemStylePlain target:self action:SELECTOR] autorelease]
+#define HBARBUTTON(TITLE, SELECTOR) [[[UIBarButtonItem alloc] initWithTitle:TITLE style:UIBarButtonItemStylePlain target:helper action:SELECTOR] autorelease]
+
+@implementation TestBedViewController
+
+- (void)textViewDidChange:(UITextView *)textView
+{
+ if (![helper isConnected]) return;
+
+ NSString *text = sendView.text;
+ if (!text || (text.length == 0)) text = @"xyzzyclear";
+ NSData *textData = [text dataUsingEncoding:NSUTF8StringEncoding];
+ [helper sendData:textData];
+}
+
+-(void) receivedData: (NSData *) data
+{
+ NSString *text = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
+ receiveView.text = [text isEqualToString:@"xyzzyclear"] ? @"" : text;
+}
+
+- (void) clear
+{
+ sendView.text = @"";
+}
+
+- (void) viewDidLoad
+{
+ self.navigationController.navigationBar.tintColor = COOKBOOK_PURPLE_COLOR;
+ self.navigationItem.leftBarButtonItem = BARBUTTON(@"Clear", @selector(clear));
+ self.navigationItem.rightBarButtonItem = HBARBUTTON(@"Connect", @selector(connect));
+
+ helper.sessionID = @"Typing Together";
+ [sendView becomeFirstResponder];
+}
+@end
+
+@interface TestBedAppDelegate : NSObject <UIApplicationDelegate>
+@end
+
+@implementation TestBedAppDelegate
+- (void)applicationDidFinishLaunching:(UIApplication *)application {
+ UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+ UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[TestBedViewController alloc] init]];
+ [window addSubview:nav.view];
+ [window makeKeyAndVisible];
+}
+@end
+
+int main(int argc, char *argv[])
+{
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ int retVal = UIApplicationMain(argc, argv, nil, @"TestBedAppDelegate");
+ [pool release];
+ return retVal;
+}

0 comments on commit e351ee9

Please sign in to comment.