Permalink
Browse files

finished converting chapter 37 code

  • Loading branch information...
1 parent 6e36293 commit eef0e4415d8bbd9e825e7228dceb7e571aebc3c0 @mattneub committed Feb 14, 2012
@@ -0,0 +1,281 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ A422AB2314EB1A0F00765842 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A422AB2214EB1A0F00765842 /* UIKit.framework */; };
+ A422AB2514EB1A0F00765842 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A422AB2414EB1A0F00765842 /* Foundation.framework */; };
+ A422AB2714EB1A0F00765842 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A422AB2614EB1A0F00765842 /* CoreGraphics.framework */; };
+ A422AB2D14EB1A0F00765842 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A422AB2B14EB1A0F00765842 /* InfoPlist.strings */; };
+ A422AB2F14EB1A0F00765842 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A422AB2E14EB1A0F00765842 /* main.m */; };
+ A422AB3314EB1A0F00765842 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A422AB3214EB1A0F00765842 /* AppDelegate.m */; };
+ A422AB3614EB1A0F00765842 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A422AB3514EB1A0F00765842 /* ViewController.m */; };
+ A422AB3914EB1A0F00765842 /* ViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A422AB3714EB1A0F00765842 /* ViewController.xib */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ A422AB1E14EB1A0F00765842 /* p757p775bonjour.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = p757p775bonjour.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ A422AB2214EB1A0F00765842 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
+ A422AB2414EB1A0F00765842 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ A422AB2614EB1A0F00765842 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+ A422AB2A14EB1A0F00765842 /* p757p775bonjour-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "p757p775bonjour-Info.plist"; sourceTree = "<group>"; };
+ A422AB2C14EB1A0F00765842 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ A422AB2E14EB1A0F00765842 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ A422AB3014EB1A0F00765842 /* p757p775bonjour-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "p757p775bonjour-Prefix.pch"; sourceTree = "<group>"; };
+ A422AB3114EB1A0F00765842 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
+ A422AB3214EB1A0F00765842 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
+ A422AB3414EB1A0F00765842 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
+ A422AB3514EB1A0F00765842 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
+ A422AB3814EB1A0F00765842 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController.xib; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ A422AB1B14EB1A0F00765842 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ A422AB2314EB1A0F00765842 /* UIKit.framework in Frameworks */,
+ A422AB2514EB1A0F00765842 /* Foundation.framework in Frameworks */,
+ A422AB2714EB1A0F00765842 /* CoreGraphics.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ A422AB1314EB1A0F00765842 = {
+ isa = PBXGroup;
+ children = (
+ A422AB2814EB1A0F00765842 /* p757p775bonjour */,
+ A422AB2114EB1A0F00765842 /* Frameworks */,
+ A422AB1F14EB1A0F00765842 /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ A422AB1F14EB1A0F00765842 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ A422AB1E14EB1A0F00765842 /* p757p775bonjour.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ A422AB2114EB1A0F00765842 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ A422AB2214EB1A0F00765842 /* UIKit.framework */,
+ A422AB2414EB1A0F00765842 /* Foundation.framework */,
+ A422AB2614EB1A0F00765842 /* CoreGraphics.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ A422AB2814EB1A0F00765842 /* p757p775bonjour */ = {
+ isa = PBXGroup;
+ children = (
+ A422AB3114EB1A0F00765842 /* AppDelegate.h */,
+ A422AB3214EB1A0F00765842 /* AppDelegate.m */,
+ A422AB3414EB1A0F00765842 /* ViewController.h */,
+ A422AB3514EB1A0F00765842 /* ViewController.m */,
+ A422AB3714EB1A0F00765842 /* ViewController.xib */,
+ A422AB2914EB1A0F00765842 /* Supporting Files */,
+ );
+ path = p757p775bonjour;
+ sourceTree = "<group>";
+ };
+ A422AB2914EB1A0F00765842 /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ A422AB2A14EB1A0F00765842 /* p757p775bonjour-Info.plist */,
+ A422AB2B14EB1A0F00765842 /* InfoPlist.strings */,
+ A422AB2E14EB1A0F00765842 /* main.m */,
+ A422AB3014EB1A0F00765842 /* p757p775bonjour-Prefix.pch */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ A422AB1D14EB1A0F00765842 /* p757p775bonjour */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = A422AB3C14EB1A0F00765842 /* Build configuration list for PBXNativeTarget "p757p775bonjour" */;
+ buildPhases = (
+ A422AB1A14EB1A0F00765842 /* Sources */,
+ A422AB1B14EB1A0F00765842 /* Frameworks */,
+ A422AB1C14EB1A0F00765842 /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = p757p775bonjour;
+ productName = p757p775bonjour;
+ productReference = A422AB1E14EB1A0F00765842 /* p757p775bonjour.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ A422AB1514EB1A0F00765842 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0420;
+ };
+ buildConfigurationList = A422AB1814EB1A0F00765842 /* Build configuration list for PBXProject "p757p775bonjour" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = A422AB1314EB1A0F00765842;
+ productRefGroup = A422AB1F14EB1A0F00765842 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ A422AB1D14EB1A0F00765842 /* p757p775bonjour */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ A422AB1C14EB1A0F00765842 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ A422AB2D14EB1A0F00765842 /* InfoPlist.strings in Resources */,
+ A422AB3914EB1A0F00765842 /* ViewController.xib in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ A422AB1A14EB1A0F00765842 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ A422AB2F14EB1A0F00765842 /* main.m in Sources */,
+ A422AB3314EB1A0F00765842 /* AppDelegate.m in Sources */,
+ A422AB3614EB1A0F00765842 /* ViewController.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ A422AB2B14EB1A0F00765842 /* InfoPlist.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ A422AB2C14EB1A0F00765842 /* en */,
+ );
+ name = InfoPlist.strings;
+ sourceTree = "<group>";
+ };
+ A422AB3714EB1A0F00765842 /* ViewController.xib */ = {
+ isa = PBXVariantGroup;
+ children = (
+ A422AB3814EB1A0F00765842 /* en */,
+ );
+ name = ViewController.xib;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ A422AB3A14EB1A0F00765842 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ SDKROOT = iphoneos;
+ };
+ name = Debug;
+ };
+ A422AB3B14EB1A0F00765842 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
+ SDKROOT = iphoneos;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ A422AB3D14EB1A0F00765842 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "p757p775bonjour/p757p775bonjour-Prefix.pch";
+ INFOPLIST_FILE = "p757p775bonjour/p757p775bonjour-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Debug;
+ };
+ A422AB3E14EB1A0F00765842 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "p757p775bonjour/p757p775bonjour-Prefix.pch";
+ INFOPLIST_FILE = "p757p775bonjour/p757p775bonjour-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ A422AB1814EB1A0F00765842 /* Build configuration list for PBXProject "p757p775bonjour" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ A422AB3A14EB1A0F00765842 /* Debug */,
+ A422AB3B14EB1A0F00765842 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ A422AB3C14EB1A0F00765842 /* Build configuration list for PBXNativeTarget "p757p775bonjour" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ A422AB3D14EB1A0F00765842 /* Debug */,
+ A422AB3E14EB1A0F00765842 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = A422AB1514EB1A0F00765842 /* Project object */;
+}
@@ -0,0 +1,12 @@
+
+#import <UIKit/UIKit.h>
+
+@class ViewController;
+
+@interface AppDelegate : UIResponder <UIApplicationDelegate>
+
+@property (strong, nonatomic) UIWindow *window;
+
+@property (strong, nonatomic) ViewController *viewController;
+
+@end
@@ -0,0 +1,22 @@
+
+
+#import "AppDelegate.h"
+
+#import "ViewController.h"
+
+@implementation AppDelegate
+
+@synthesize window = _window;
+@synthesize viewController = _viewController;
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+ // Override point for customization after application launch.
+ self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
+ self.window.rootViewController = self.viewController;
+ [self.window makeKeyAndVisible];
+ return YES;
+}
+
+@end
@@ -0,0 +1,7 @@
+
+#import <UIKit/UIKit.h>
+
+
+@interface ViewController : UIViewController <NSNetServiceBrowserDelegate, NSNetServiceDelegate>
+
+@end
@@ -0,0 +1,61 @@
+
+#import "ViewController.h"
+
+@interface ViewController ()
+@property (nonatomic, retain) NSNetServiceBrowser* nsb;
+@property (nonatomic, retain) NSMutableArray* services;
+@end
+
+@implementation ViewController
+@synthesize nsb, services;
+
+// tap button, watch console when you turn on Sharing in iTunes
+
+- (IBAction)doButton:(id)sender {
+ NSLog(@"listening for services...");
+ self.services = [NSMutableArray array];
+ NSNetServiceBrowser* browser = [[NSNetServiceBrowser alloc] init];
+ self.nsb = browser;
+ self.nsb.delegate = self;
+ [self.nsb searchForServicesOfType:@"_daap._tcp" inDomain:@""];
+}
+
+- (void) updateInterface {
+ for (NSNetService* service in self.services) {
+ if (service.port == -1) {
+ NSLog(@"service %@ of type %@, not yet resolved",
+ service.name, service.type);
+ [service setDelegate:self];
+ [service resolveWithTimeout:10];
+ } else {
+ NSLog(@"service %@ of type %@, port %i, addresses %@",
+ service.name, service.type, service.port, service.addresses);
+ }
+ }
+}
+
+- (void)netServiceDidResolveAddress:(NSNetService *)sender {
+ [self updateInterface];
+}
+
+- (void)netServiceBrowser:(NSNetServiceBrowser *)netServiceBrowser
+ didFindService:(NSNetService *)netService
+ moreComing:(BOOL)moreServicesComing {
+ [self.services addObject:netService];
+ NSLog(@"adding a service");
+ if (!moreServicesComing)
+ [self updateInterface];
+}
+
+- (void)netServiceBrowser:(NSNetServiceBrowser *)netServiceBrowser
+ didRemoveService:(NSNetService *)netService
+ moreComing:(BOOL)moreServicesComing {
+ [self.services removeObject:netService];
+ NSLog(@"removing a service");
+ if (!moreServicesComing)
+ [self updateInterface];
+}
+
+
+
+@end
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
Oops, something went wrong.

0 comments on commit eef0e44

Please sign in to comment.