From dfd019de7d31ddfbfdf98844b607b6f771700e14 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Latour Date: Mon, 5 May 2014 13:18:04 -0700 Subject: [PATCH] Update README.md --- README.md | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0af6661..e25dfd6 100644 --- a/README.md +++ b/README.md @@ -77,8 +77,10 @@ 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 (Ctrl-C in Terminal) or SIGTERM is received [webServer runWithPort:8080 bonjourName:nil]; + NSLog(@"Visit %@ in your web browser", webServer.serverURL); } return 0; @@ -90,7 +92,12 @@ int main(int argc, const char* argv[]) { #import "GCDWebServer.h" #import "GCDWebServerDataResponse.h" -static GCDWebServer* _webServer = nil; // This should really be an ivar of your application's delegate class +@interface AppDelegate : NSObject { + GCDWebServer* _webServer; +} +@end + +@implementation AppDelegate - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { @@ -108,9 +115,12 @@ static GCDWebServer* _webServer = nil; // This should really be an ivar of your // Start server on port 8080 [_webServer startWithPort:8080 bonjourName:nil]; + NSLog(@"Visit %@ in your web browser", _webServer.serverURL); return YES; } + +@end ``` Web Based Uploads in iOS Apps @@ -123,7 +133,12 @@ Simply instantiate and run a ```GCDWebUploader``` instance then visit ```http:// ```objectivec #import "GCDWebUploader.h" -static GCDWebUploader* _webUploader = nil; // This should really be an ivar of your application's delegate class +@interface AppDelegate : NSObject { + GCDWebUploader* _webUploader; +} +@end + +@implementation AppDelegate - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]; @@ -132,6 +147,8 @@ static GCDWebUploader* _webUploader = nil; // This should really be an ivar of NSLog(@"Visit %@ in your web browser", _webUploader.serverURL); return YES; } + +@end ``` WebDAV Server in iOS Apps @@ -146,7 +163,12 @@ Simply instantiate and run a ```GCDWebDAVServer``` instance then connect to ```h ```objectivec #import "GCDWebDAVServer.h" -static GCDWebDAVServer* _davServer = nil; // This should really be an ivar of your application's delegate class +@interface AppDelegate : NSObject { + GCDWebDAVServer* _davServer; +} +@end + +@implementation AppDelegate - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions { NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]; @@ -155,6 +177,8 @@ static GCDWebDAVServer* _davServer = nil; // This should really be an ivar of y NSLog(@"Visit %@ in your WebDAV client", _davServer.serverURL); return YES; } + +@end ``` Serving a Static Website