Update README.md

This commit is contained in:
Pierre-Olivier Latour 2014-04-15 01:28:46 -03:00
parent bb0f62416e
commit ad01c15dcd

View File

@ -79,7 +79,7 @@ int main(int argc, const char* argv[]) {
// Use convenience method that runs server on port 8080 until SIGINT received (i.e. Ctrl-C in Terminal) // Use convenience method that runs server on port 8080 until SIGINT received (i.e. Ctrl-C in Terminal)
[webServer runWithPort:8080]; [webServer runWithPort:8080];
// Destroy server // Destroy server (unnecessary if using ARC)
[webServer release]; [webServer release];
} }
@ -91,7 +91,7 @@ int main(int argc, const char* argv[]) {
```objectivec ```objectivec
#import "GCDWebServer.h" #import "GCDWebServer.h"
static GCDWebServer* _webServer = nil; // This should be an ivar of your application delegate class instead static GCDWebServer* _webServer = nil; // This should really be an ivar of your application delegate class
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
@ -124,11 +124,13 @@ Simply instantiate and run a GCDWebUploader instance then visit http://{YOUR-IOS
```objectivec ```objectivec
#import "GCDWebUploader.h" #import "GCDWebUploader.h"
static GCDWebUploader* _webUploader = nil; // This should really be an ivar of your application delegate class
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]; NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
GCDWebUploader* webUploader = [[GCDWebUploader alloc] initWithUploadDirectory:documentsPath]; _webUploader = [[GCDWebUploader alloc] initWithUploadDirectory:documentsPath];
[webUploader start]; [_webUploader start];
NSLog(@"Visit %@ in your web browser", webUploader.serverURL); NSLog(@"Visit %@ in your web browser", _webUploader.serverURL);
return YES; return YES;
} }
``` ```
@ -145,11 +147,13 @@ Simply instantiate and run a GCDWebDAVServer instance then connect to http://{YO
```objectivec ```objectivec
#import "GCDWebDAVServer.h" #import "GCDWebDAVServer.h"
static GCDWebDAVServer* _davServer = nil; // This should really be an ivar of your application delegate class
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]; NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
GCDWebDAVServer* davServer = [[GCDWebDAVServer alloc] initWithUploadDirectory:documentsPath]; _davServer = [[GCDWebDAVServer alloc] initWithUploadDirectory:documentsPath];
[davServer start]; [_davServer start];
NSLog(@"Visit %@ in your WebDAV client", davServer.serverURL); NSLog(@"Visit %@ in your WebDAV client", _davServer.serverURL);
return YES; return YES;
} }
``` ```
@ -168,7 +172,7 @@ int main(int argc, const char* argv[]) {
GCDWebServer* webServer = [[GCDWebServer alloc] init]; GCDWebServer* webServer = [[GCDWebServer alloc] init];
[webServer addGETHandlerForBasePath:@"/" directoryPath:NSHomeDirectory() indexFilename:nil cacheAge:3600 allowRangeRequests:YES]; [webServer addGETHandlerForBasePath:@"/" directoryPath:NSHomeDirectory() indexFilename:nil cacheAge:3600 allowRangeRequests:YES];
[webServer runWithPort:8080]; [webServer runWithPort:8080];
[webServer release]; [webServer release]; // Remove if using ARC
} }
return 0; return 0;