Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use [NSDictionary objectForKey:] instead of [NSDictionary valueForKey…
…:] to access objects in dictionaries

Summary: valueForKey also works in this case since none of our keys are strings staring with "@". However, objectForKey: is the correct selector to use for the desired behavior.

Test Plan: Verify behavior with HackBook app

Reviewers: jacl, dgibson

Reviewed By: jacl

Differential Revision: https://phabricator.fb.com/D427850

Task ID: 854847
  • Loading branch information
suhasjoshi committed Mar 14, 2012
1 parent f6ae975 commit 84e953c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/FBRequest.m
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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;

}
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/Facebook.m
Expand Up @@ -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.
Expand All @@ -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"]);
Expand All @@ -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];
Expand Down

0 comments on commit 84e953c

Please sign in to comment.