Permalink
Browse files

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...
1 parent f6ae975 commit 84e953c24dcb2eee7e7e5760b555163486010df3 @suhasjoshi suhasjoshi committed Mar 14, 2012
Showing with 11 additions and 11 deletions.
  1. +7 −7 src/FBRequest.m
  2. +4 −4 src/Facebook.m
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
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 84e953c

Please sign in to comment.