From 5de22f5146abf273f1d54aeeb29c02e651d63b7b Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 12 Jun 2015 11:21:55 -0700 Subject: [PATCH] Removed what I could, fixed some nits --- .../HelloWorld.xcodeproj/project.pbxproj | 12 ---- .../HelloWorld/HelloWorld/AppDelegate.h | 40 ++++++++--- .../HelloWorld/HelloWorld/AppDelegate.m | 71 +++++++++---------- .../HelloWorld/Base.lproj/LaunchScreen.xib | 41 ----------- objective-c/HelloWorld/HelloWorld/Info.plist | 2 +- .../HelloWorld/HelloWorld/ViewController.h | 39 ++++++++-- .../HelloWorld/HelloWorld/ViewController.m | 53 ++++++++------ objective-c/HelloWorld/HelloWorld/main.m | 41 ++++++++--- objective-c/HelloWorld/README.md | 12 ++-- 9 files changed, 169 insertions(+), 142 deletions(-) delete mode 100644 objective-c/HelloWorld/HelloWorld/Base.lproj/LaunchScreen.xib diff --git a/objective-c/HelloWorld/HelloWorld.xcodeproj/project.pbxproj b/objective-c/HelloWorld/HelloWorld.xcodeproj/project.pbxproj index 6cc49ead373..9a7b3057e09 100644 --- a/objective-c/HelloWorld/HelloWorld.xcodeproj/project.pbxproj +++ b/objective-c/HelloWorld/HelloWorld.xcodeproj/project.pbxproj @@ -12,7 +12,6 @@ 5E36906C1B2A23800040F884 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E36906B1B2A23800040F884 /* ViewController.m */; }; 5E36906F1B2A23800040F884 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5E36906D1B2A23800040F884 /* Main.storyboard */; }; 5E3690711B2A23800040F884 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5E3690701B2A23800040F884 /* Images.xcassets */; }; - 5E3690741B2A23800040F884 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5E3690721B2A23800040F884 /* LaunchScreen.xib */; }; 5E3690801B2A23800040F884 /* HelloWorldTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E36907F1B2A23800040F884 /* HelloWorldTests.m */; }; EF61CF6AE2536A31D47F0E63 /* libPods-HelloWorld.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B4E1F55F8A2EC95A0E7EE88 /* libPods-HelloWorld.a */; }; /* End PBXBuildFile section */ @@ -38,7 +37,6 @@ 5E36906B1B2A23800040F884 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 5E36906E1B2A23800040F884 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 5E3690701B2A23800040F884 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; - 5E3690731B2A23800040F884 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 5E3690791B2A23800040F884 /* HelloWorldTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HelloWorldTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 5E36907E1B2A23800040F884 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 5E36907F1B2A23800040F884 /* HelloWorldTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HelloWorldTests.m; sourceTree = ""; }; @@ -94,7 +92,6 @@ 5E36906B1B2A23800040F884 /* ViewController.m */, 5E36906D1B2A23800040F884 /* Main.storyboard */, 5E3690701B2A23800040F884 /* Images.xcassets */, - 5E3690721B2A23800040F884 /* LaunchScreen.xib */, 5E3690631B2A23800040F884 /* Supporting Files */, ); path = HelloWorld; @@ -226,7 +223,6 @@ buildActionMask = 2147483647; files = ( 5E36906F1B2A23800040F884 /* Main.storyboard in Resources */, - 5E3690741B2A23800040F884 /* LaunchScreen.xib in Resources */, 5E3690711B2A23800040F884 /* Images.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -311,14 +307,6 @@ name = Main.storyboard; sourceTree = ""; }; - 5E3690721B2A23800040F884 /* LaunchScreen.xib */ = { - isa = PBXVariantGroup; - children = ( - 5E3690731B2A23800040F884 /* Base */, - ); - name = LaunchScreen.xib; - sourceTree = ""; - }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ diff --git a/objective-c/HelloWorld/HelloWorld/AppDelegate.h b/objective-c/HelloWorld/HelloWorld/AppDelegate.h index b1eaba90a4f..b1857f28e08 100644 --- a/objective-c/HelloWorld/HelloWorld/AppDelegate.h +++ b/objective-c/HelloWorld/HelloWorld/AppDelegate.h @@ -1,10 +1,35 @@ -// -// AppDelegate.h -// HelloWorld -// -// Created by Michael Lumish on 6/11/15. -// Copyright (c) 2015 Google. All rights reserved. -// +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ #import @@ -12,6 +37,5 @@ @property (strong, nonatomic) UIWindow *window; - @end diff --git a/objective-c/HelloWorld/HelloWorld/AppDelegate.m b/objective-c/HelloWorld/HelloWorld/AppDelegate.m index cd6498d058d..27b1f00f989 100644 --- a/objective-c/HelloWorld/HelloWorld/AppDelegate.m +++ b/objective-c/HelloWorld/HelloWorld/AppDelegate.m @@ -1,45 +1,38 @@ -// -// AppDelegate.m -// HelloWorld -// -// Created by Michael Lumish on 6/11/15. -// Copyright (c) 2015 Google. All rights reserved. -// +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ #import "AppDelegate.h" -@interface AppDelegate () - -@end - @implementation AppDelegate - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - // Override point for customization after application launch. - return YES; -} - -- (void)applicationWillResignActive:(UIApplication *)application { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. -} - -- (void)applicationDidEnterBackground:(UIApplication *)application { - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. -} - -- (void)applicationWillEnterForeground:(UIApplication *)application { - // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. -} - -- (void)applicationDidBecomeActive:(UIApplication *)application { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. -} - -- (void)applicationWillTerminate:(UIApplication *)application { - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. -} - @end diff --git a/objective-c/HelloWorld/HelloWorld/Base.lproj/LaunchScreen.xib b/objective-c/HelloWorld/HelloWorld/Base.lproj/LaunchScreen.xib deleted file mode 100644 index 8fcc4fd8ed5..00000000000 --- a/objective-c/HelloWorld/HelloWorld/Base.lproj/LaunchScreen.xib +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/objective-c/HelloWorld/HelloWorld/Info.plist b/objective-c/HelloWorld/HelloWorld/Info.plist index 77352c99aa4..1078fff7235 100644 --- a/objective-c/HelloWorld/HelloWorld/Info.plist +++ b/objective-c/HelloWorld/HelloWorld/Info.plist @@ -23,7 +23,7 @@ LSRequiresIPhoneOS UILaunchStoryboardName - LaunchScreen + Main UIMainStoryboardFile Main UIRequiredDeviceCapabilities diff --git a/objective-c/HelloWorld/HelloWorld/ViewController.h b/objective-c/HelloWorld/HelloWorld/ViewController.h index c822a66cedc..38cd7f92b66 100644 --- a/objective-c/HelloWorld/HelloWorld/ViewController.h +++ b/objective-c/HelloWorld/HelloWorld/ViewController.h @@ -1,10 +1,35 @@ -// -// ViewController.h -// HelloWorld -// -// Created by Michael Lumish on 6/11/15. -// Copyright (c) 2015 Google. All rights reserved. -// +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ #import diff --git a/objective-c/HelloWorld/HelloWorld/ViewController.m b/objective-c/HelloWorld/HelloWorld/ViewController.m index 5aa4441879b..91df435ed92 100644 --- a/objective-c/HelloWorld/HelloWorld/ViewController.m +++ b/objective-c/HelloWorld/HelloWorld/ViewController.m @@ -1,27 +1,38 @@ -// -// ViewController.m -// HelloWorld -// -// Created by Michael Lumish on 6/11/15. -// Copyright (c) 2015 Google. All rights reserved. -// +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ #import "ViewController.h" -@interface ViewController () - -@end - @implementation ViewController -- (void)viewDidLoad { - [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - @end diff --git a/objective-c/HelloWorld/HelloWorld/main.m b/objective-c/HelloWorld/HelloWorld/main.m index c912b6345a2..458580be302 100644 --- a/objective-c/HelloWorld/HelloWorld/main.m +++ b/objective-c/HelloWorld/HelloWorld/main.m @@ -1,10 +1,35 @@ -// -// main.m -// HelloWorld -// -// Created by Michael Lumish on 6/11/15. -// Copyright (c) 2015 Google. All rights reserved. -// +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ #import #import "AppDelegate.h" @@ -17,7 +42,7 @@ int main(int argc, char * argv[]) { @autoreleasepool { HLWGreeter *client = [[HLWGreeter alloc] initWithHost:kHostAddress]; HLWHelloRequest *request = [HLWHelloRequest message]; - request.name = @"Objective C"; + request.name = @"Objective-C"; [client sayHelloWithRequest:request handler:^(HLWHelloReply *response, NSError *error) { NSLog(@"%@", response.message); }]; diff --git a/objective-c/HelloWorld/README.md b/objective-c/HelloWorld/README.md index db3bcb18fe7..cb25882867c 100644 --- a/objective-c/HelloWorld/README.md +++ b/objective-c/HelloWorld/README.md @@ -1,12 +1,12 @@ -#gRPC in 3 minutes (Objective C) +#gRPC in 3 minutes (Objective-C) ## Installation To run this example you should have [Cocoapods](https://cocoapods.org/#install) installed, as well as the relevant tools to generate the client library code (and a server in another language, for testing). You can obtain the latter by following [these setup instructions](https://github.com/grpc/homebrew-grpc). -## Hello Objective C gRPC! +## Hello Objective-C gRPC! -Here's how to build and run the Objective C implementation of the [Hello World](https://github.com/grpc/grpc-common/blob/master/protos/helloworld.proto) example used in [Getting started](https://github.com/grpc/grpc-common). +Here's how to build and run the Objective-C implementation of the [Hello World](https://github.com/grpc/grpc-common/blob/master/protos/helloworld.proto) example used in [Getting started](https://github.com/grpc/grpc-common). The example code for this and our other examples lives in the `grpc-common` GitHub repository. Clone this repository to your local machine by running the @@ -17,7 +17,7 @@ following command: $ git clone https://github.com/grpc/grpc-common.git ``` -Change your current directory to grpc-common/objective-c/HelloWorld +Change your current directory to `grpc-common/objective-c/HelloWorld` ```sh $ cd grpc-common/objective-c/HelloWorld @@ -43,6 +43,8 @@ This might have to compile OpenSSL, which takes around 15 minutes if Cocoapods d Finally, open the XCode workspace created by Cocoapods, and run the app. You can check the calling code in `Supporting Files/main.m` and see the results in XCode's log console. +The code sends a `HLWHelloRequest` containing the string "Objective-C" to a local server. The server responds with a `HLWHelloResponse`, which contains a string that is then output to the log. + ## Tutorial -You can find a more detailed tutorial in [gRPC Basics: Objective C](https://github.com/grpc/grpc-common/blob/master/objective-c/route_guide/README.md) \ No newline at end of file +You can find a more detailed tutorial in [gRPC Basics: Objective-C](https://github.com/grpc/grpc-common/blob/master/objective-c/route_guide/README.md) \ No newline at end of file