Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: jmurty/three20
base: master
...
head fork: jdelStrother/three20
compare: master
  • 3 commits
  • 11 files changed
  • 0 commit comments
  • 2 contributors
Commits on Jun 10, 2009
Joe Hewitt joehewitt * Method to create an NSURLRequest from a TTURLRequest
* Method to load a request in a TTWebController
* Bug fixes in search bars
b5e86f3
Commits on Jun 12, 2009
Jonathan del Strother Fix leak on -[TTURLRequestLoader cancel:] bf49af8
Commits on Jul 03, 2009
Jonathan del Strother SDKROOT -> 3.0, DEPLOYMENT_TARGET -> 2.2.1
Having a nightmare persuading my app to run on both 2.2.1 & 3.0 without hardcoding these settings in three20's xcodeproj
Not quite ready to move to 3.0-only yet...
83ff6e5
1  src/TTGlobal.m
View
@@ -109,7 +109,6 @@ BOOL TTOSVersionIsAtLeast(float version) {
return NO;
}
-
NSLocale* TTCurrentLocale() {
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
NSArray* languages = [defaults objectForKey:@"AppleLanguages"];
5 src/TTSearchBar.m
View
@@ -70,8 +70,9 @@ - (void)scrollToTop {
UIScrollView* scrollView = (UIScrollView*)[self firstParentOfClass:[UIScrollView class]];
if (scrollView) {
CGPoint offset = scrollView.contentOffset;
- if (offset.y != self.top) {
- [scrollView setContentOffset:CGPointMake(offset.x, self.top) animated:YES];
+ CGPoint myOffset = [self offsetFromView:scrollView];
+ if (offset.y != myOffset.y) {
+ [scrollView setContentOffset:CGPointMake(offset.x, myOffset.y) animated:YES];
}
}
}
11 src/TTSearchTextField.m
View
@@ -63,10 +63,6 @@ - (void)textFieldDidEndEditing:(UITextField *)textField {
if ([_delegate respondsToSelector:@selector(textFieldDidEndEditing:)]) {
[_delegate textFieldDidEndEditing:textField];
}
-
- if (_textField.dataSource) {
- textField.text = @"";
- }
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range
@@ -104,7 +100,7 @@ - (BOOL)textFieldShouldReturn:(UITextField *)textField {
if (!_textField.searchesAutomatically) {
[_textField search];
} else {
- [_textField resignFirstResponder];
+ [_textField performSelector:@selector(doneAction)];
}
}
return shouldReturn;
@@ -222,6 +218,7 @@ - (void)autoSearch {
[self search];
}
}
+
- (void)dispatchUpdate:(NSTimer*)timer {
_searchTimer = nil;
[self autoSearch];
@@ -253,6 +250,10 @@ - (void)screenAnimationDidStop {
- (void)doneAction {
[self resignFirstResponder];
+
+ if (self.dataSource) {
+ self.text = @"";
+ }
}
///////////////////////////////////////////////////////////////////////////////////////////////////
2  src/TTThumbsViewController.m
View
@@ -221,7 +221,7 @@ - (void)loadView {
CGFloat y = TTOSVersionIsAtLeast(3.0) ? 0 : -CHROME_HEIGHT;
CGRect innerFrame = CGRectMake(0, y,
screenFrame.size.width, screenFrame.size.height + CHROME_HEIGHT);
- UIView* innerView = [[UIView alloc] initWithFrame:innerFrame];
+ UIView* innerView = [[[UIView alloc] initWithFrame:innerFrame] autorelease];
innerView.backgroundColor = TTSTYLEVAR(backgroundColor);
[self.view addSubview:innerView];
4 src/TTURLRequest.m
View
@@ -206,6 +206,10 @@ - (void)cancel {
[[TTURLRequestQueue mainQueue] cancelRequest:self];
}
+- (NSURLRequest*)createNSURLRequest {
+ return [[TTURLRequestQueue mainQueue] createNSURLRequest:self url:nil];
+}
+
@end
//////////////////////////////////////////////////////////////////////////////////////////////////
59 src/TTURLRequestQueue.m
View
@@ -87,31 +87,9 @@ - (void)connectToURL:(NSURL*)url {
TTLOG(@"Connecting to %@", _url);
TTNetworkRequestStarted();
- NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url
- cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
- timeoutInterval:kTimeout];
- [urlRequest setValue:_queue.userAgent forHTTPHeaderField:@"User-Agent"];
+ TTURLRequest* request = _requests.count == 1 ? [_requests objectAtIndex:0] : nil;
+ NSURLRequest *urlRequest = [_queue createNSURLRequest:request url:url];
- if (_requests.count == 1) {
- TTURLRequest* request = [_requests objectAtIndex:0];
- [urlRequest setHTTPShouldHandleCookies:request.shouldHandleCookies];
-
- NSString* method = request.httpMethod;
- if (method) {
- [urlRequest setHTTPMethod:method];
- }
-
- NSString* contentType = request.contentType;
- if (contentType) {
- [urlRequest setValue:contentType forHTTPHeaderField:@"Content-Type"];
- }
-
- NSData* body = request.httpBody;
- if (body) {
- [urlRequest setHTTPBody:body];
- }
- }
-
_connection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
}
@@ -263,6 +241,7 @@ - (BOOL)cancel:(TTURLRequest*)request {
if (_connection) {
TTNetworkRequestStopped();
[_connection cancel];
+ [_connection release];
_connection = nil;
}
return NO;
@@ -611,4 +590,36 @@ - (void)cancelAllRequests {
}
}
+- (NSURLRequest*)createNSURLRequest:(TTURLRequest*)request url:(NSURL*)url {
+ if (!url) {
+ url = [NSURL URLWithString:request.url];
+ }
+
+ NSMutableURLRequest* urlRequest = [NSMutableURLRequest requestWithURL:url
+ cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
+ timeoutInterval:kTimeout];
+ [urlRequest setValue:self.userAgent forHTTPHeaderField:@"User-Agent"];
+
+ if (request) {
+ [urlRequest setHTTPShouldHandleCookies:request.shouldHandleCookies];
+
+ NSString* method = request.httpMethod;
+ if (method) {
+ [urlRequest setHTTPMethod:method];
+ }
+
+ NSString* contentType = request.contentType;
+ if (contentType) {
+ [urlRequest setValue:contentType forHTTPHeaderField:@"Content-Type"];
+ }
+
+ NSData* body = request.httpBody;
+ if (body) {
+ [urlRequest setHTTPBody:body];
+ }
+ }
+
+ return urlRequest;
+}
+
@end
8 src/TTWebController.m
View
@@ -169,6 +169,11 @@ - (NSURL*)url {
return _webView.request.URL;
}
+- (void)openRequest:(NSURLRequest*)request {
+ self.view;
+ [_webView loadRequest:request];
+}
+
- (void)setHeaderView:(UIView*)headerView {
if (headerView != _headerView) {
BOOL addingHeader = !_headerView && headerView;
@@ -195,9 +200,8 @@ - (void)setHeaderView:(UIView*)headerView {
}
- (void)openURL:(NSURL*)url {
- self.view;
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url];
- [_webView loadRequest:request];
+ [self openRequest:request];
}
@end
6 src/Three20.xcodeproj/project.pbxproj
View
@@ -775,10 +775,11 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = .;
+ IPHONEOS_DEPLOYMENT_TARGET = 2.2.1;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-ObjC";
PREBINDING = NO;
- SDKROOT = iphonesimulator2.2;
+ SDKROOT = iphoneos3.0;
};
name = Debug;
};
@@ -790,9 +791,10 @@
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 2.2.1;
OTHER_LDFLAGS = "-ObjC";
PREBINDING = NO;
- SDKROOT = iphonesimulator2.2;
+ SDKROOT = iphoneos3.0;
};
name = Release;
};
2  src/Three20/TTURLRequest.h
View
@@ -101,6 +101,8 @@
*/
- (void)cancel;
+- (NSURLRequest*)createNSURLRequest;
+
@end
///////////////////////////////////////////////////////////////////////////////////////////////////
5 src/Three20/TTURLRequestQueue.h
View
@@ -76,4 +76,9 @@
*/
- (void)cancelAllRequests;
+/**
+ * Creates a Cocoa URL request from a Three20 URL request.
+ */
+- (NSURLRequest*)createNSURLRequest:(TTURLRequest*)request url:(NSURL*)url;
+
@end
1  src/Three20/TTWebController.h
View
@@ -19,6 +19,7 @@
@property(nonatomic,retain) UIView* headerView;
- (void)openURL:(NSURL*)url;
+- (void)openRequest:(NSURLRequest*)request;
@end

No commit comments for this range

Something went wrong with that request. Please try again.