Skip to content

Commit 23f5e8f

Browse files
committed
Adding mobile version of UdpEchoServer example
1 parent 0dee5a4 commit 23f5e8f

File tree

13 files changed

+1137
-10
lines changed

13 files changed

+1137
-10
lines changed

GCD/Xcode/UdpEchoClient/Mobile/UdpEchoClient/ViewController.m

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ - (void)viewDidLoad
8383

8484
- (void)viewDidUnload
8585
{
86+
[super viewDidUnload];
87+
8688
[[NSNotificationCenter defaultCenter] removeObserver:self];
8789
}
8890

@@ -184,11 +186,8 @@ - (void)logError:(NSString *)msg
184186
NSString *suffix = @"</font><br/>";
185187

186188
[log appendFormat:@"%@%@%@\n", prefix, msg, suffix];
187-
DDLogVerbose(@"log: %@", log);
188189

189190
NSString *html = [NSString stringWithFormat:@"<html><body>\n%@\n</body></html>", log];
190-
DDLogVerbose(@"html:\n%@", html);
191-
192191
[webView loadHTMLString:html baseURL:nil];
193192
}
194193

@@ -198,11 +197,8 @@ - (void)logInfo:(NSString *)msg
198197
NSString *suffix = @"</font><br/>";
199198

200199
[log appendFormat:@"%@%@%@\n", prefix, msg, suffix];
201-
DDLogVerbose(@"log: %@", log);
202200

203201
NSString *html = [NSString stringWithFormat:@"<html><body>\n%@\n</body></html>", log];
204-
DDLogVerbose(@"html:\n%@", html);
205-
206202
[webView loadHTMLString:html baseURL:nil];
207203
}
208204

@@ -212,11 +208,8 @@ - (void)logMessage:(NSString *)msg
212208
NSString *suffix = @"</font><br/>";
213209

214210
[log appendFormat:@"%@%@%@\n", prefix, msg, suffix];
215-
DDLogVerbose(@"log: %@", log);
216211

217212
NSString *html = [NSString stringWithFormat:@"<html><body>%@</body></html>", log];
218-
DDLogVerbose(@"html:\n%@", html);
219-
220213
[webView loadHTMLString:html baseURL:nil];
221214
}
222215

GCD/Xcode/UdpEchoServer/Desktop/UdpEchoServer/AppDelegate.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
2626
// However, it will invoke the delegate methods on a specified GCD delegate dispatch queue.
2727
//
2828
// Now we can configure the delegate dispatch queues however we want.
29-
// We could simply use the main dispatc queue, so the delegate methods are invoked on the main thread.
29+
// We could simply use the main dispatch queue, so the delegate methods are invoked on the main thread.
3030
// Or we could use a dedicated dispatch queue, which could be helpful if we were doing a lot of processing.
3131
//
3232
// The best approach for your application will depend upon convenience, requirements and performance.

GCD/Xcode/UdpEchoServer/Mobile/UdpEchoServer.xcodeproj/project.pbxproj

Lines changed: 359 additions & 0 deletions
Large diffs are not rendered by default.

GCD/Xcode/UdpEchoServer/Mobile/UdpEchoServer.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#import <UIKit/UIKit.h>
2+
3+
@class ViewController;
4+
5+
6+
@interface AppDelegate : UIResponder <UIApplicationDelegate>
7+
8+
@property (strong, nonatomic) UIWindow *window;
9+
@property (strong, nonatomic) ViewController *viewController;
10+
11+
@end
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#import "AppDelegate.h"
2+
#import "ViewController.h"
3+
#import "DDLog.h"
4+
#import "DDTTYLogger.h"
5+
6+
// Log levels: off, error, warn, info, verbose
7+
static const int ddLogLevel = LOG_LEVEL_VERBOSE;
8+
9+
10+
@implementation AppDelegate
11+
12+
@synthesize window = _window;
13+
@synthesize viewController = _viewController;
14+
15+
16+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
17+
{
18+
// Setup our logging framework.
19+
20+
[DDLog addLogger:[DDTTYLogger sharedInstance]];
21+
22+
// Setup UI
23+
24+
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
25+
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
26+
self.window.rootViewController = self.viewController;
27+
[self.window makeKeyAndVisible];
28+
return YES;
29+
}
30+
31+
- (void)applicationWillResignActive:(UIApplication *)application
32+
{
33+
}
34+
35+
- (void)applicationDidEnterBackground:(UIApplication *)application
36+
{
37+
}
38+
39+
- (void)applicationWillEnterForeground:(UIApplication *)application
40+
{
41+
}
42+
43+
- (void)applicationDidBecomeActive:(UIApplication *)application
44+
{
45+
}
46+
47+
- (void)applicationWillTerminate:(UIApplication *)application
48+
{
49+
}
50+
51+
@end
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>${PRODUCT_NAME}</string>
9+
<key>CFBundleExecutable</key>
10+
<string>${EXECUTABLE_NAME}</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>com.deusty.${PRODUCT_NAME:rfc1034identifier}</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>${PRODUCT_NAME}</string>
17+
<key>CFBundlePackageType</key>
18+
<string>APPL</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0</string>
21+
<key>CFBundleSignature</key>
22+
<string>????</string>
23+
<key>CFBundleVersion</key>
24+
<string>1.0</string>
25+
<key>LSRequiresIPhoneOS</key>
26+
<true/>
27+
<key>UIRequiredDeviceCapabilities</key>
28+
<array>
29+
<string>armv7</string>
30+
</array>
31+
<key>UISupportedInterfaceOrientations</key>
32+
<array>
33+
<string>UIInterfaceOrientationPortrait</string>
34+
<string>UIInterfaceOrientationLandscapeLeft</string>
35+
<string>UIInterfaceOrientationLandscapeRight</string>
36+
</array>
37+
</dict>
38+
</plist>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// Prefix header for all source files of the 'UdpEchoServer' target in the 'UdpEchoServer' project
3+
//
4+
5+
#import <Availability.h>
6+
7+
#ifndef __IPHONE_4_0
8+
#warning "This project uses features only available in iOS SDK 4.0 and later."
9+
#endif
10+
11+
#ifdef __OBJC__
12+
#import <UIKit/UIKit.h>
13+
#import <Foundation/Foundation.h>
14+
#endif
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#import <UIKit/UIKit.h>
2+
3+
4+
@interface ViewController : UIViewController
5+
{
6+
IBOutlet UITextField *portField;
7+
IBOutlet UIButton *startStopButton;
8+
IBOutlet UIWebView *webView;
9+
}
10+
11+
- (IBAction)startStop:(id)sender;
12+
13+
@end

0 commit comments

Comments
 (0)