Ben Copsey

Use nanotech's rotation code for ASIAuthenticationDialog instead - it's animated…

…, and seems to be more reliable on iOS3 device
Fix deprecated warning in ASIDownloadCache
Tweaks to sample iphone app - rotation fixes, remove bandwidth use bar for now
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 8
9 #import "ASIAuthenticationDialog.h" 9 #import "ASIAuthenticationDialog.h"
10 #import "ASIHTTPRequest.h" 10 #import "ASIHTTPRequest.h"
11 -#import <CoreGraphics/CoreGraphics.h> 11 +#import <QuartzCore/QuartzCore.h>
12 12
13 static ASIAuthenticationDialog *sharedDialog = nil; 13 static ASIAuthenticationDialog *sharedDialog = nil;
14 BOOL isDismissing = NO; 14 BOOL isDismissing = NO;
@@ -127,33 +127,46 @@ static const NSUInteger kDomainSection = 1; @@ -127,33 +127,46 @@ static const NSUInteger kDomainSection = 1;
127 // Manually handles orientation changes on iPhone 127 // Manually handles orientation changes on iPhone
128 - (void)orientationChanged:(NSNotification *)notification 128 - (void)orientationChanged:(NSNotification *)notification
129 { 129 {
130 - [[self view] setTransform:CGAffineTransformIdentity];  
131 [self showTitle]; 130 [self showTitle];
132 - CGRect frame = [[self view] frame]; 131 +
133 - [[self view] setCenter:CGPointMake(frame.size.height/2,frame.size.width/2)]; 132 + UIDeviceOrientation o = [[UIApplication sharedApplication] statusBarOrientation];
134 - float targetRotation = 0; 133 + CGFloat angle = 0;
135 - 134 + switch (o) {
136 - frame = [[UIScreen mainScreen] bounds]; 135 + case UIDeviceOrientationLandscapeLeft: angle = 90; break;
137 - switch ([[UIDevice currentDevice] orientation]) { 136 + case UIDeviceOrientationLandscapeRight: angle = -90; break;
138 - case UIDeviceOrientationPortraitUpsideDown: 137 + case UIDeviceOrientationPortraitUpsideDown: angle = 180; break;
139 - targetRotation = 180; 138 + default: break;
140 - frame = CGRectMake(0, 0, frame.size.width, frame.size.height-20);  
141 - break;  
142 - case UIDeviceOrientationLandscapeLeft:  
143 - targetRotation = 90;  
144 - frame = CGRectMake(0, 0, frame.size.width-20, frame.size.height);  
145 - break;  
146 - case UIDeviceOrientationLandscapeRight:  
147 - frame = CGRectMake(20, 0, frame.size.width-20, frame.size.height);  
148 - targetRotation = 270;  
149 - break;  
150 - case UIDeviceOrientationPortrait:  
151 - frame = CGRectMake(0, 20, frame.size.width, frame.size.height-20);  
152 - break;  
153 } 139 }
154 140
155 - [[self view] setTransform:CGAffineTransformMakeRotation(targetRotation / 180.0 * M_PI)]; 141 + CGRect f = [[UIScreen mainScreen] applicationFrame];
156 - [[self view] setFrame:frame]; 142 +
  143 + // Swap the frame height and width if necessary
  144 + if (UIDeviceOrientationIsLandscape(o)) {
  145 + CGFloat t;
  146 + t = f.size.width;
  147 + f.size.width = f.size.height;
  148 + f.size.height = t;
  149 + }
  150 +
  151 + CGAffineTransform previousTransform = self.view.layer.affineTransform;
  152 + CGAffineTransform newTransform = CGAffineTransformMakeRotation(angle * M_PI / 180.0);
  153 +
  154 + // Reset the transform so we can set the size
  155 + self.view.layer.affineTransform = CGAffineTransformIdentity;
  156 + self.view.frame = (CGRect){0,0,f.size};
  157 +
  158 + // Revert to the previous transform for correct animation
  159 + self.view.layer.affineTransform = previousTransform;
  160 +
  161 + [UIView beginAnimations:nil context:NULL];
  162 + [UIView setAnimationDuration:0.3];
  163 +
  164 + // Set the new transform
  165 + self.view.layer.affineTransform = newTransform;
  166 +
  167 + // Fix the view origin
  168 + self.view.frame = (CGRect){f.origin.x,f.origin.y,self.view.frame.size};
  169 + [UIView commitAnimations];
157 } 170 }
158 171
159 #pragma mark utilities 172 #pragma mark utilities
@@ -165,7 +178,7 @@ static const NSUInteger kDomainSection = 1; @@ -165,7 +178,7 @@ static const NSUInteger kDomainSection = 1;
165 178
166 // Attach to the window, but don't interfere. 179 // Attach to the window, but don't interfere.
167 UIWindow *window = [[[UIApplication sharedApplication] windows] objectAtIndex:0]; 180 UIWindow *window = [[[UIApplication sharedApplication] windows] objectAtIndex:0];
168 - [window addSubview:presentingController.view]; 181 + [window addSubview:[presentingController view]];
169 [[presentingController view] setFrame:CGRectZero]; 182 [[presentingController view] setFrame:CGRectZero];
170 [[presentingController view] setUserInteractionEnabled:NO]; 183 [[presentingController view] setUserInteractionEnabled:NO];
171 } 184 }
@@ -61,7 +61,7 @@ static NSString *permanentCacheFolder = @"PermanentStore"; @@ -61,7 +61,7 @@ static NSString *permanentCacheFolder = @"PermanentStore";
61 [[self accessLock] unlock]; 61 [[self accessLock] unlock];
62 [NSException raise:@"FileExistsAtCachePath" format:@"Cannot create a directory for the cache at '%@', because a file already exists",directory]; 62 [NSException raise:@"FileExistsAtCachePath" format:@"Cannot create a directory for the cache at '%@', because a file already exists",directory];
63 } else if (!exists) { 63 } else if (!exists) {
64 - [[NSFileManager defaultManager] createDirectoryAtPath:directory attributes:nil]; 64 + [[NSFileManager defaultManager] createDirectoryAtPath:directory withIntermediateDirectories:NO attributes:nil error:nil];
65 if (![[NSFileManager defaultManager] fileExistsAtPath:directory]) { 65 if (![[NSFileManager defaultManager] fileExistsAtPath:directory]) {
66 [[self accessLock] unlock]; 66 [[self accessLock] unlock];
67 [NSException raise:@"FailedToCreateCacheDirectory" format:@"Failed to create a directory for the cache at '%@'",directory]; 67 [NSException raise:@"FailedToCreateCacheDirectory" format:@"Failed to create a directory for the cache at '%@'",directory];
@@ -296,10 +296,10 @@ static NSString *permanentCacheFolder = @"PermanentStore"; @@ -296,10 +296,10 @@ static NSString *permanentCacheFolder = @"PermanentStore";
296 return; 296 return;
297 } 297 }
298 NSString *path; 298 NSString *path;
299 - if (storagePolicy == ASICacheForSessionDurationCacheStoragePolicy) { 299 + if (storagePolicy == ASICachePermanentlyCacheStoragePolicy) {
300 - path = [[self storagePath] stringByAppendingPathComponent:sessionCacheFolder];  
301 - } else if (storagePolicy == ASICachePermanentlyCacheStoragePolicy) {  
302 path = [[self storagePath] stringByAppendingPathComponent:permanentCacheFolder]; 300 path = [[self storagePath] stringByAppendingPathComponent:permanentCacheFolder];
  301 + } else {
  302 + path = [[self storagePath] stringByAppendingPathComponent:sessionCacheFolder];
303 } 303 }
304 BOOL isDirectory = NO; 304 BOOL isDirectory = NO;
305 BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDirectory]; 305 BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDirectory];
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 24
25 // Automatically set on build 25 // Automatically set on build
26 26
27 -NSString *ASIHTTPRequestVersion = @"v1.7-9 2010-06-30"; 27 +NSString *ASIHTTPRequestVersion = @"v1.7-10 2010-07-02";
28 28
29 NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain"; 29 NSString* const NetworkRequestErrorDomain = @"ASIHTTPRequestErrorDomain";
30 30
@@ -111,6 +111,8 @@ @@ -111,6 +111,8 @@
111 [responseField setBackgroundColor:[UIColor clearColor]]; 111 [responseField setBackgroundColor:[UIColor clearColor]];
112 [responseField setEditable:NO]; 112 [responseField setEditable:NO];
113 [responseField setText:@"Secret information will appear here if authentication succeeds"]; 113 [responseField setText:@"Secret information will appear here if authentication succeeds"];
  114 + [[self view] setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
  115 +
114 } 116 }
115 117
116 static NSString *intro = @"Demonstrates fetching content from an area that requires HTTP authentication. You will be prompted for a username and password, enter 'topsecret' for both.\nIf you turn on keychain support, successful authentication will result in the username and password you provided being stored in your keychain. The application will use these details rather than prompt you the next time.\nToggle 'Use built-in dialog' to switch between ASIHTTPRequest's built-in dialog, and one created by the delegate."; 118 static NSString *intro = @"Demonstrates fetching content from an area that requires HTTP authentication. You will be prompted for a username and password, enter 'topsecret' for both.\nIf you turn on keychain support, successful authentication will result in the username and password you provided being stored in your keychain. The application will use these details rather than prompt you the next time.\nToggle 'Use built-in dialog' to switch between ASIHTTPRequest's built-in dialog, and one created by the delegate.";
@@ -94,6 +94,7 @@ @@ -94,6 +94,7 @@
94 - (void)viewDidLoad 94 - (void)viewDidLoad
95 { 95 {
96 [[[self navigationBar] topItem] setTitle:@"Using a Queue"]; 96 [[[self navigationBar] topItem] setTitle:@"Using a Queue"];
  97 + [[self view] setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
97 } 98 }
98 99
99 static NSString *intro = @"Demonstrates a fetching 3 items at once, using an ASINetworkQueue to track progress.\r\nEach request has its own downloadProgressDelegate, and the queue has an additional downloadProgressDelegate to track overall progress."; 100 static NSString *intro = @"Demonstrates a fetching 3 items at once, using an ASINetworkQueue to track progress.\r\nEach request has its own downloadProgressDelegate, and the queue has an additional downloadProgressDelegate to track overall progress.";
@@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
13 <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> 13 <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
14 <bool key="EncodedWithXMLCoder">YES</bool> 14 <bool key="EncodedWithXMLCoder">YES</bool>
15 <integer value="2"/> 15 <integer value="2"/>
16 - <integer value="106"/> 16 + <integer value="126"/>
17 </object> 17 </object>
18 <object class="NSArray" key="IBDocument.PluginDependencies"> 18 <object class="NSArray" key="IBDocument.PluginDependencies">
19 <bool key="EncodedWithXMLCoder">YES</bool> 19 <bool key="EncodedWithXMLCoder">YES</bool>
@@ -46,18 +46,6 @@ @@ -46,18 +46,6 @@
46 <int key="NSvFlags">1316</int> 46 <int key="NSvFlags">1316</int>
47 <object class="NSMutableArray" key="NSSubviews"> 47 <object class="NSMutableArray" key="NSSubviews">
48 <bool key="EncodedWithXMLCoder">YES</bool> 48 <bool key="EncodedWithXMLCoder">YES</bool>
49 - <object class="IBUIToolbar" id="565443135">  
50 - <reference key="NSNextResponder" ref="380026005"/>  
51 - <int key="NSvFlags">1290</int>  
52 - <string key="NSFrame">{{0, -1}, {320, 44}}</string>  
53 - <reference key="NSSuperview" ref="380026005"/>  
54 - <bool key="IBUIOpaque">NO</bool>  
55 - <bool key="IBUIClearsContextBeforeDrawing">NO</bool>  
56 - <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>  
57 - <object class="NSMutableArray" key="IBUIItems">  
58 - <bool key="EncodedWithXMLCoder">YES</bool>  
59 - </object>  
60 - </object>  
61 <object class="IBUILabel" id="633748759"> 49 <object class="IBUILabel" id="633748759">
62 <reference key="NSNextResponder" ref="380026005"/> 50 <reference key="NSNextResponder" ref="380026005"/>
63 <int key="NSvFlags">1316</int> 51 <int key="NSvFlags">1316</int>
@@ -207,15 +195,7 @@ @@ -207,15 +195,7 @@
207 <reference key="source" ref="664661524"/> 195 <reference key="source" ref="664661524"/>
208 <reference key="destination" ref="1034742383"/> 196 <reference key="destination" ref="1034742383"/>
209 </object> 197 </object>
210 - <int key="connectionID">113</int> 198 + <int key="connectionID">147</int>
211 - </object>  
212 - <object class="IBConnectionRecord">  
213 - <object class="IBCocoaTouchOutletConnection" key="connection">  
214 - <string key="label">statusMessage</string>  
215 - <reference key="source" ref="664661524"/>  
216 - <reference key="destination" ref="633748759"/>  
217 - </object>  
218 - <int key="connectionID">129</int>  
219 </object> 199 </object>
220 </object> 200 </object>
221 <object class="IBMutableOrderedSet" key="objectRecords"> 201 <object class="IBMutableOrderedSet" key="objectRecords">
@@ -232,7 +212,6 @@ @@ -232,7 +212,6 @@
232 <reference key="object" ref="380026005"/> 212 <reference key="object" ref="380026005"/>
233 <object class="NSMutableArray" key="children"> 213 <object class="NSMutableArray" key="children">
234 <bool key="EncodedWithXMLCoder">YES</bool> 214 <bool key="EncodedWithXMLCoder">YES</bool>
235 - <reference ref="565443135"/>  
236 <reference ref="633748759"/> 215 <reference ref="633748759"/>
237 </object> 216 </object>
238 <reference key="parent" ref="0"/> 217 <reference key="parent" ref="0"/>
@@ -332,11 +311,6 @@ @@ -332,11 +311,6 @@
332 <reference key="object" ref="633748759"/> 311 <reference key="object" ref="633748759"/>
333 <reference key="parent" ref="380026005"/> 312 <reference key="parent" ref="380026005"/>
334 </object> 313 </object>
335 - <object class="IBObjectRecord">  
336 - <int key="objectID">130</int>  
337 - <reference key="object" ref="565443135"/>  
338 - <reference key="parent" ref="380026005"/>  
339 - </object>  
340 </object> 314 </object>
341 </object> 315 </object>
342 <object class="NSMutableDictionary" key="flattenedProperties"> 316 <object class="NSMutableDictionary" key="flattenedProperties">
@@ -357,7 +331,6 @@ @@ -357,7 +331,6 @@
357 <string>124.CustomClassName</string> 331 <string>124.CustomClassName</string>
358 <string>126.CustomClassName</string> 332 <string>126.CustomClassName</string>
359 <string>128.IBPluginDependency</string> 333 <string>128.IBPluginDependency</string>
360 - <string>130.IBPluginDependency</string>  
361 <string>2.IBAttributePlaceholdersKey</string> 334 <string>2.IBAttributePlaceholdersKey</string>
362 <string>2.IBEditorWindowLastContentRect</string> 335 <string>2.IBEditorWindowLastContentRect</string>
363 <string>2.IBPluginDependency</string> 336 <string>2.IBPluginDependency</string>
@@ -368,7 +341,7 @@ @@ -368,7 +341,7 @@
368 <bool key="EncodedWithXMLCoder">YES</bool> 341 <bool key="EncodedWithXMLCoder">YES</bool>
369 <string>UIApplication</string> 342 <string>UIApplication</string>
370 <string>UIResponder</string> 343 <string>UIResponder</string>
371 - <string>{{474, 471}, {320, 480}}</string> 344 + <string>{{654, 389}, {320, 480}}</string>
372 <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> 345 <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
373 <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> 346 <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
374 <string>SynchronousViewController</string> 347 <string>SynchronousViewController</string>
@@ -380,7 +353,6 @@ @@ -380,7 +353,6 @@
380 <string>UploadViewController</string> 353 <string>UploadViewController</string>
381 <string>AuthenticationViewController</string> 354 <string>AuthenticationViewController</string>
382 <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> 355 <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
383 - <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>  
384 <object class="NSMutableDictionary"> 356 <object class="NSMutableDictionary">
385 <bool key="EncodedWithXMLCoder">YES</bool> 357 <bool key="EncodedWithXMLCoder">YES</bool>
386 <reference key="dict.sortedKeys" ref="0"/> 358 <reference key="dict.sortedKeys" ref="0"/>
@@ -410,7 +382,7 @@ @@ -410,7 +382,7 @@
410 </object> 382 </object>
411 </object> 383 </object>
412 <nil key="sourceID"/> 384 <nil key="sourceID"/>
413 - <int key="maxID">131</int> 385 + <int key="maxID">147</int>
414 </object> 386 </object>
415 <object class="IBClassDescriber" key="IBDocument.Classes"> 387 <object class="IBClassDescriber" key="IBDocument.Classes">
416 <object class="NSMutableArray" key="referencedPartialClassDescriptions"> 388 <object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -497,7 +469,7 @@ @@ -497,7 +469,7 @@
497 </object> 469 </object>
498 <object class="IBClassDescriptionSource" key="sourceIdentifier"> 470 <object class="IBClassDescriptionSource" key="sourceIdentifier">
499 <string key="majorKey">IBProjectSource</string> 471 <string key="majorKey">IBProjectSource</string>
500 - <string key="minorKey">SampleViewController.h</string> 472 + <string key="minorKey">iPhone Sample/SampleViewController.h</string>
501 </object> 473 </object>
502 </object> 474 </object>
503 <object class="IBPartialClassDescription"> 475 <object class="IBPartialClassDescription">
@@ -577,13 +549,11 @@ @@ -577,13 +549,11 @@
577 <bool key="EncodedWithXMLCoder">YES</bool> 549 <bool key="EncodedWithXMLCoder">YES</bool>
578 <object class="NSArray" key="dict.sortedKeys"> 550 <object class="NSArray" key="dict.sortedKeys">
579 <bool key="EncodedWithXMLCoder">YES</bool> 551 <bool key="EncodedWithXMLCoder">YES</bool>
580 - <string>statusMessage</string>  
581 <string>tabBarController</string> 552 <string>tabBarController</string>
582 <string>window</string> 553 <string>window</string>
583 </object> 554 </object>
584 <object class="NSMutableArray" key="dict.values"> 555 <object class="NSMutableArray" key="dict.values">
585 <bool key="EncodedWithXMLCoder">YES</bool> 556 <bool key="EncodedWithXMLCoder">YES</bool>
586 - <string>UILabel</string>  
587 <string>UITabBarController</string> 557 <string>UITabBarController</string>
588 <string>UIWindow</string> 558 <string>UIWindow</string>
589 </object> 559 </object>
@@ -592,17 +562,12 @@ @@ -592,17 +562,12 @@
592 <bool key="EncodedWithXMLCoder">YES</bool> 562 <bool key="EncodedWithXMLCoder">YES</bool>
593 <object class="NSArray" key="dict.sortedKeys"> 563 <object class="NSArray" key="dict.sortedKeys">
594 <bool key="EncodedWithXMLCoder">YES</bool> 564 <bool key="EncodedWithXMLCoder">YES</bool>
595 - <string>statusMessage</string>  
596 <string>tabBarController</string> 565 <string>tabBarController</string>
597 <string>window</string> 566 <string>window</string>
598 </object> 567 </object>
599 <object class="NSMutableArray" key="dict.values"> 568 <object class="NSMutableArray" key="dict.values">
600 <bool key="EncodedWithXMLCoder">YES</bool> 569 <bool key="EncodedWithXMLCoder">YES</bool>
601 <object class="IBToOneOutletInfo"> 570 <object class="IBToOneOutletInfo">
602 - <string key="name">statusMessage</string>  
603 - <string key="candidateClassName">UILabel</string>  
604 - </object>  
605 - <object class="IBToOneOutletInfo">  
606 <string key="name">tabBarController</string> 571 <string key="name">tabBarController</string>
607 <string key="candidateClassName">UITabBarController</string> 572 <string key="candidateClassName">UITabBarController</string>
608 </object> 573 </object>
@@ -41,6 +41,7 @@ Most of the code below here relates to the table view, and isn't that interestin @@ -41,6 +41,7 @@ Most of the code below here relates to the table view, and isn't that interestin
41 - (void)viewDidLoad 41 - (void)viewDidLoad
42 { 42 {
43 [[[self navigationBar] topItem] setTitle:@"Synchronous Requests"]; 43 [[[self navigationBar] topItem] setTitle:@"Synchronous Requests"];
  44 + [[self view] setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
44 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; 45 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
45 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; 46 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
46 47
@@ -74,6 +74,8 @@ @@ -74,6 +74,8 @@
74 resultView = [[UITextView alloc] initWithFrame:CGRectZero]; 74 resultView = [[UITextView alloc] initWithFrame:CGRectZero];
75 [resultView setBackgroundColor:[UIColor clearColor]]; 75 [resultView setBackgroundColor:[UIColor clearColor]];
76 progressIndicator = [[UIProgressView alloc] initWithFrame:CGRectZero]; 76 progressIndicator = [[UIProgressView alloc] initWithFrame:CGRectZero];
  77 + [[self view] setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
  78 +
77 } 79 }
78 80
79 static NSString *intro = @"Demonstrates POSTing content to a URL, showing upload progress.\nYou'll only see accurate progress for uploads when the request body is larger than 128KB (in 2.2.1 SDK), or when the request body is larger than 32KB (in 3.0 SDK)"; 81 static NSString *intro = @"Demonstrates POSTing content to a URL, showing upload progress.\nYou'll only see accurate progress for uploads when the request body is larger than 128KB (in 2.2.1 SDK), or when the request body is larger than 32KB (in 3.0 SDK)";
@@ -9,13 +9,10 @@ @@ -9,13 +9,10 @@
9 #import <UIKit/UIKit.h> 9 #import <UIKit/UIKit.h>
10 10
11 @interface iPhoneSampleAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> { 11 @interface iPhoneSampleAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
12 - UIWindow *window; 12 + IBOutlet UIWindow *window;
13 - UITabBarController *tabBarController; 13 + IBOutlet UITabBarController *tabBarController;
14 - IBOutlet UILabel *statusMessage;  
15 -  
16 } 14 }
17 15
18 -@property (nonatomic, retain) IBOutlet UIWindow *window; 16 +@property (nonatomic, retain) UIWindow *window;
19 -@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;  
20 17
21 @end 18 @end
@@ -7,44 +7,22 @@ @@ -7,44 +7,22 @@
7 // 7 //
8 8
9 #import "iPhoneSampleAppDelegate.h" 9 #import "iPhoneSampleAppDelegate.h"
10 -#import "ASIHTTPRequest.h"  
11 -#import "Reachability.h"  
12 10
13 @implementation iPhoneSampleAppDelegate 11 @implementation iPhoneSampleAppDelegate
14 12
15 -- (void)dealloc 13 +- (void)applicationDidFinishLaunching:(UIApplication *)application
16 { 14 {
17 - [tabBarController release]; 15 + [[tabBarController view] setFrame:CGRectMake(0, 0, 320, 480)];
18 - [window release]; 16 + [window addSubview:[tabBarController view]];
19 - [super dealloc];  
20 -}  
21 -  
22 -- (void)applicationDidFinishLaunching:(UIApplication *)application {  
23 - // Add the tab bar controller's current view as a subview of the window  
24 - [window addSubview:[tabBarController view]];  
25 - [[tabBarController view] setFrame:CGRectMake(0,42,320,438)];  
26 - [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateStatus:) userInfo:nil repeats:YES];  
27 } 17 }
28 18
29 -// 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! 19 +- (void)dealloc
30 -- (void)updateStatus:(NSTimer *)timer  
31 { 20 {
32 - NSString *connectionType; 21 + [window release];
33 - if ([ASIHTTPRequest isNetworkReachableViaWWAN]) { 22 + [super dealloc];
34 - connectionType = @"Using WWAN";  
35 - } else {  
36 - connectionType = @"Not using WWAN";  
37 - }  
38 - NSString *throttling = @"Throttling OFF";  
39 - if ([ASIHTTPRequest isBandwidthThrottled]) {  
40 - throttling = @"Throttling ON";  
41 - }  
42 - [statusMessage setText:[NSString stringWithFormat:@"%@ / %luKB per second / %@",connectionType, [ASIHTTPRequest averageBandwidthUsedPerSecond]/1024,throttling]];  
43 } 23 }
44 24
45 -  
46 @synthesize window; 25 @synthesize window;
47 -@synthesize tabBarController;  
48 26
49 @end 27 @end
50 28
This diff was suppressed by a .gitattributes entry.