Permalink
Browse files

Merge branch 'master' of git://github.com/facebook/facebook-ios-sdk

  • Loading branch information...
2 parents 3d812a7 + 07626c3 commit d37f11ff22fefb85315fba674d426ebf08c2f660 @qwzybug committed Mar 23, 2012
@@ -559,6 +559,7 @@ - (void)enableFrictionlessAppRequests {
otherButtonTitles:nil,
nil];
[alertView show];
+ [alertView release];
}
/*
@@ -697,6 +698,8 @@ - (void)apiGraphUserPhotosPost {
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
img, @"picture",
nil];
+ [img release];
+
[[delegate facebook] requestWithGraphPath:@"me/photos"
andParams:params
andHttpMethod:@"POST"
@@ -995,15 +998,17 @@ - (void)request:(FBRequest *)request didLoad:(id)result {
NSMutableArray *friendsWithApp = [[NSMutableArray alloc] initWithCapacity:1];
// Many results
if ([result isKindOfClass:[NSArray class]]) {
- friendsWithApp = [[NSMutableArray alloc] initWithArray:result copyItems:YES];
+ [friendsWithApp addObjectsFromArray:result];
} else if ([result isKindOfClass:[NSDecimalNumber class]]) {
- friendsWithApp = [[NSMutableArray alloc] initWithObjects:[result stringValue], nil];
+ [friendsWithApp addObject: [result stringValue]];
}
+
if ([friendsWithApp count] > 0) {
[self apiDialogRequestsSendToUsers:friendsWithApp];
} else {
[self showMessage:@"None of your friends are using the app."];
}
+
[friendsWithApp release];
break;
}
@@ -290,9 +290,6 @@ - (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)respons
* didReceiveResponse:(NSURLResponse *)response
*/
- (void)request:(FBRequest *)request didLoad:(id)result {
- if ([result isKindOfClass:[NSArray class]]) {
- result = [result objectAtIndex:0];
- }
[self showMessage:@"Checked in successfully"];
}
@@ -373,8 +373,9 @@ - (void)fbSessionInvalidated {
#pragma mark - FBRequestDelegate Methods
/**
- * Called when the Facebook API request has returned a response. This callback
- * gives you access to the raw response. It's called before
+ * Called when the Facebook API request has returned a response.
+ *
+ * This callback gives you access to the raw response. It's called before
* (void)request:(FBRequest *)request didLoad:(id)result,
* which is passed the parsed response object.
*/
@@ -384,9 +385,11 @@ - (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)respons
/**
* Called when a request returns and its response has been parsed into
- * an object. The resulting object may be a dictionary, an array, a string,
- * or a number, depending on the format of the API response. If you need access
- * to the raw response, use:
+ * an object.
+ *
+ * The resulting object may be a dictionary, an array or a string, depending
+ * on the format of the API response. If you need access to the raw response,
+ * use:
*
* (void)request:(FBRequest *)request
* didReceiveResponse:(NSURLResponse *)response
@@ -426,10 +429,10 @@ - (void)request:(FBRequest *)request didLoad:(id)result {
UIGraphicsBeginImageContext(CGSizeMake(px, px));
UIRectClip(clipRect);
[image drawInRect:clipRect];
- UIImage *imgThumb = UIGraphicsGetImageFromCurrentImageContext();
- [imgThumb retain];
-
+ UIImage *imgThumb = UIGraphicsGetImageFromCurrentImageContext();
+ UIGraphicsEndImageContext();
[profilePhotoImageView setImage:imgThumb];
+
[self apiGraphUserPermissions];
} else {
// Processing permissions information
View
@@ -367,6 +367,11 @@ - (id)init {
_spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:
UIActivityIndicatorViewStyleWhiteLarge];
+ if ([_spinner respondsToSelector:@selector(setColor:)]) {
+ [_spinner setColor:[UIColor grayColor]];
+ } else {
+ [_spinner setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
+ }
_spinner.autoresizingMask =
UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin
| UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
@@ -568,7 +573,7 @@ - (NSString *) getStringFromUrl: (NSString*) url needle:(NSString *) needle {
if (start.location != 0) {
c = [url characterAtIndex:start.location - 1];
}
- if (c == '?' || c == '&') {
+ if (c == '?' || c == '&' || c == '#') {
NSRange end = [[url substringFromIndex:start.location+start.length] rangeOfString:@"&"];
NSUInteger offset = start.location+start.length;
str = end.location == NSNotFound ?
View
@@ -105,7 +105,11 @@ typedef NSUInteger FBRequestState;
- (void)requestLoading:(FBRequest *)request;
/**
- * Called when the server responds and begins to send back data.
+ * Called when the Facebook API request has returned a response.
+ *
+ * This callback gives you access to the raw response. It's called before
+ * (void)request:(FBRequest *)request didLoad:(id)result,
+ * which is passed the parsed response object.
*/
- (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)response;
@@ -118,8 +122,12 @@ typedef NSUInteger FBRequestState;
* Called when a request returns and its response has been parsed into
* an object.
*
- * The resulting object may be a dictionary, an array, a string, or a number,
- * depending on thee format of the API response.
+ * The resulting object may be a dictionary, an array or a string, depending
+ * on the format of the API response. If you need access to the raw response,
+ * use:
+ *
+ * (void)request:(FBRequest *)request
+ * didReceiveResponse:(NSURLResponse *)response
*/
- (void)request:(FBRequest *)request didLoad:(id)result;
View
@@ -85,8 +85,8 @@ + (NSString*)serializeURL:(NSString *)baseUrl
NSMutableArray* pairs = [NSMutableArray array];
for (NSString* key in [params keyEnumerator]) {
- if (([[params valueForKey:key] isKindOfClass:[UIImage class]])
- ||([[params valueForKey:key] isKindOfClass:[NSData class]])) {
+ if (([[params objectForKey:key] isKindOfClass:[UIImage class]])
+ ||([[params objectForKey:key] isKindOfClass:[NSData class]])) {
if ([httpMethod isEqualToString:@"GET"]) {
NSLog(@"can not use GET to upload a file");
}
@@ -127,10 +127,10 @@ - (NSMutableData *)generatePostBody {
for (id key in [_params keyEnumerator]) {
- if (([[_params valueForKey:key] isKindOfClass:[UIImage class]])
- ||([[_params valueForKey:key] isKindOfClass:[NSData class]])) {
+ if (([[_params objectForKey:key] isKindOfClass:[UIImage class]])
+ ||([[_params objectForKey:key] isKindOfClass:[NSData class]])) {
- [dataDictionary setObject:[_params valueForKey:key] forKey:key];
+ [dataDictionary setObject:[_params objectForKey:key] forKey:key];
continue;
}
@@ -139,14 +139,14 @@ - (NSMutableData *)generatePostBody {
data:[NSString
stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n",
key]];
- [self utfAppendBody:body data:[_params valueForKey:key]];
+ [self utfAppendBody:body data:[_params objectForKey:key]];
[self utfAppendBody:body data:endLine];
}
if ([dataDictionary count] > 0) {
for (id key in dataDictionary) {
- NSObject *dataParam = [dataDictionary valueForKey:key];
+ NSObject *dataParam = [dataDictionary objectForKey:key];
if ([dataParam isKindOfClass:[UIImage class]]) {
NSData* imageData = UIImagePNGRepresentation((UIImage*)dataParam);
[self utfAppendBody:body
@@ -189,7 +189,6 @@ - (id)parseJsonResponse:(NSData *)data error:(NSError **)error {
NSString* responseString = [[[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding]
autorelease];
- SBJSON *jsonParser = [[SBJSON new] autorelease];
if ([responseString isEqualToString:@"true"]) {
return [NSDictionary dictionaryWithObject:@"true" forKey:@"result"];
} else if ([responseString isEqualToString:@"false"]) {
@@ -203,9 +202,15 @@ - (id)parseJsonResponse:(NSData *)data error:(NSError **)error {
}
+ SBJSON *jsonParser = [[SBJSON alloc] init];
id result = [jsonParser objectWithString:responseString];
-
- if (![result isKindOfClass:[NSArray class]]) {
+ [jsonParser release];
+
+ if (result == nil) {
+ return responseString;
+ }
+
+ if ([result isKindOfClass:[NSDictionary class]]) {
if ([result objectForKey:@"error"] != nil) {
if (error != nil) {
*error = [self formError:kGeneralErrorCode
@@ -272,7 +277,7 @@ - (void)handleResponseData:(NSData *)data {
[self failWithError:error];
} else if ([_delegate respondsToSelector:
@selector(request:didLoad:)]) {
- [_delegate request:self didLoad:(result == nil ? data : result)];
+ [_delegate request:self didLoad:result];
}
}
View
@@ -415,11 +415,11 @@ - (BOOL)handleOpenURL:(NSURL *)url {
}
NSDictionary *params = [self parseURLParams:query];
- NSString *accessToken = [params valueForKey:@"access_token"];
+ NSString *accessToken = [params objectForKey:@"access_token"];
// If the URL doesn't contain the access token, an error has occurred.
if (!accessToken) {
- NSString *errorReason = [params valueForKey:@"error"];
+ NSString *errorReason = [params objectForKey:@"error"];
// If the error response indicates that we should try again using Safari, open
// the authorization dialog in Safari.
@@ -438,7 +438,7 @@ - (BOOL)handleOpenURL:(NSURL *)url {
// The facebook app may return an error_code parameter in case it
// encounters a UIWebViewDelegate error. This should not be treated
// as a cancel.
- NSString *errorCode = [params valueForKey:@"error_code"];
+ NSString *errorCode = [params objectForKey:@"error_code"];
BOOL userDidCancel =
!errorCode && (!errorReason || [errorReason isEqualToString:@"access_denied"]);
@@ -447,7 +447,7 @@ - (BOOL)handleOpenURL:(NSURL *)url {
}
// We have an access token, so parse the expiration date.
- NSString *expTime = [params valueForKey:@"expires_in"];
+ NSString *expTime = [params objectForKey:@"expires_in"];
NSDate *expirationDate = [NSDate distantFuture];
if (expTime != nil) {
int expVal = [expTime intValue];

0 comments on commit d37f11f

Please sign in to comment.