iPhoneHTTPServerAppDelegate.m.svn-base
上传用户:kc0325
上传日期:2020-06-20
资源大小:204k
文件大小:1k
源码类别:

iPhone

开发平台:

Objective-C

  1. //
  2. //  iPhoneHTTPServerAppDelegate.m
  3. //  iPhoneHTTPServer
  4. //
  5. //  Created by Nonnus on 11/22/08.
  6. //  Copyright __MyCompanyName__ 2008. All rights reserved.
  7. //
  8. #import "iPhoneHTTPServerAppDelegate.h"
  9. #import "HTTPServer.h"
  10. #import "FileBrowser.h"
  11. #import "localhostAdresses.h"
  12. @implementation iPhoneHTTPServerAppDelegate
  13. @synthesize window;
  14. - (void)applicationDidFinishLaunching:(UIApplication *)application 
  15. {
  16.    [window makeKeyAndVisible];
  17. NSString *root = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES) objectAtIndex:0];
  18. httpServer = [HTTPServer new];
  19. [httpServer setType:@"_http._tcp."];
  20. [httpServer setName:@"iTM Matrix"];
  21. [httpServer setDocumentRoot:[NSURL fileURLWithPath:root]];
  22. UINavigationController *browser = [[UINavigationController alloc] initWithRootViewController:[[FileBrowser alloc] initWithRoot:root title:@"iTM Matrix" server:httpServer]];
  23. [window addSubview:browser.view];
  24. NSError *error;
  25. if(![httpServer start:&error])
  26. {
  27. NSLog(@"Error starting HTTP Server: %@", error);
  28. }
  29. [localhostAdresses list];
  30. //[localhostAdresses performSelectorInBackground:@selector(list) withObject:nil];
  31. }
  32. - (void)dealloc 
  33. {
  34. [httpServer release];
  35.     [window release];
  36.     [super dealloc];
  37. }
  38. @end