iPhoneSampleAppDelegate.m
1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// iPhoneSampleAppDelegate.m
// asi-http-request
//
// Created by Ben Copsey on 07/11/2008.
// Copyright All-Seeing Interactive 2008. All rights reserved.
//
#import "iPhoneSampleAppDelegate.h"
#import "ASIHTTPRequest.h"
#import "Reachability.h"
@implementation iPhoneSampleAppDelegate
@synthesize window;
@synthesize tabBarController;
- (void)dealloc {
[tabBarController release];
[window release];
[super dealloc];
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Add the tab bar controller's current view as a subview of the window
[window addSubview:[tabBarController view]];
[[tabBarController view] setFrame:CGRectMake(0,47,320,433)];
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateStatus:) userInfo:nil repeats:YES];
}
// This is really just so I can test reachability + throttling is working. Please don't use a timer to do this in your own apps!
- (void)updateStatus:(NSTimer *)timer
{
NSString *connectionType;
if ([ASIHTTPRequest isNetworkReachableViaWWAN]) {
connectionType = @"Using WWAN";
} else {
connectionType = @"Not using WWAN";
}
NSString *throttling = @"Throttling OFF";
if ([ASIHTTPRequest isBandwidthThrottled]) {
throttling = @"Throttling ON";
}
[statusMessage setText:[NSString stringWithFormat:@"%@ / %luKB per second / %@",connectionType, [ASIHTTPRequest averageBandwidthUsedPerSecond]/1024,throttling]];
}
@end