Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Changed params to NSDictionary

I cannot even begin to express how bad of an idea requiring a mutable dictionary is.
  • Loading branch information...
commit 2f9a00bc339803a766534bed89671f6f1223e5e7 1 parent 8b445f4
@davbeck authored
View
6 src/FBRequest.h
@@ -34,7 +34,7 @@ typedef NSUInteger FBRequestState;
id<FBRequestDelegate> _delegate;
NSString* _url;
NSString* _httpMethod;
- NSMutableDictionary* _params;
+ NSDictionary* _params;
NSURLConnection* _connection;
NSMutableData* _responseText;
FBRequestState _state;
@@ -61,7 +61,7 @@ typedef NSUInteger FBRequestState;
* These values in the dictionary will be converted to strings using the
* standard Objective-C object-to-string conversion facilities.
*/
-@property(nonatomic,retain) NSMutableDictionary* params;
+@property(nonatomic,retain) NSDictionary* params;
@property(nonatomic,retain) NSURLConnection* connection;
@property(nonatomic,retain) NSMutableData* responseText;
@property(nonatomic,readonly) FBRequestState state;
@@ -80,7 +80,7 @@ typedef NSUInteger FBRequestState;
params:(NSDictionary *)params
httpMethod:(NSString *)httpMethod;
-+ (FBRequest*)getRequestWithParams:(NSMutableDictionary *) params
++ (FBRequest*)getRequestWithParams:(NSDictionary *) params
httpMethod:(NSString *) httpMethod
delegate:(id<FBRequestDelegate>)delegate
requestURL:(NSString *) url;
View
2  src/FBRequest.m
@@ -49,7 +49,7 @@ @implementation FBRequest
//////////////////////////////////////////////////////////////////////////////////////////////////
// class public
-+ (FBRequest *)getRequestWithParams:(NSMutableDictionary *) params
++ (FBRequest *)getRequestWithParams:(NSDictionary *) params
httpMethod:(NSString *) httpMethod
delegate:(id<FBRequestDelegate>) delegate
requestURL:(NSString *) url {
View
10 src/Facebook.h
@@ -70,11 +70,11 @@
- (void)logout:(id<FBSessionDelegate>)delegate;
-- (FBRequest*)requestWithParams:(NSMutableDictionary *)params
+- (FBRequest*)requestWithParams:(NSDictionary *)params
andDelegate:(id <FBRequestDelegate>)delegate;
- (FBRequest*)requestWithMethodName:(NSString *)methodName
- andParams:(NSMutableDictionary *)params
+ andParams:(NSDictionary *)params
andHttpMethod:(NSString *)httpMethod
andDelegate:(id <FBRequestDelegate>)delegate;
@@ -82,11 +82,11 @@
andDelegate:(id <FBRequestDelegate>)delegate;
- (FBRequest*)requestWithGraphPath:(NSString *)graphPath
- andParams:(NSMutableDictionary *)params
+ andParams:(NSDictionary *)params
andDelegate:(id <FBRequestDelegate>)delegate;
- (FBRequest*)requestWithGraphPath:(NSString *)graphPath
- andParams:(NSMutableDictionary *)params
+ andParams:(NSDictionary *)params
andHttpMethod:(NSString *)httpMethod
andDelegate:(id <FBRequestDelegate>)delegate;
@@ -94,7 +94,7 @@
andDelegate:(id<FBDialogDelegate>)delegate;
- (void)dialog:(NSString *)action
- andParams:(NSMutableDictionary *)params
+ andParams:(NSDictionary *)params
andDelegate:(id <FBDialogDelegate>)delegate;
- (BOOL)isSessionValid;
View
46 src/Facebook.m
@@ -165,7 +165,7 @@ - (void)invalidateSession {
* the request has received response
*/
- (FBRequest*)openUrl:(NSString *)url
- params:(NSMutableDictionary *)params
+ params:(NSDictionary *)params
httpMethod:(NSString *)httpMethod
delegate:(id<FBRequestDelegate>)delegate {
@@ -512,18 +512,20 @@ - (void)logout:(id<FBSessionDelegate>)delegate {
* @return FBRequest*
* Returns a pointer to the FBRequest object.
*/
-- (FBRequest*)requestWithParams:(NSMutableDictionary *)params
+- (FBRequest*)requestWithParams:(NSDictionary *)params
andDelegate:(id <FBRequestDelegate>)delegate {
- if ([params objectForKey:@"method"] == nil) {
+ NSMutableDictionary *mutableParams = [params mutableCopy];
+
+ if ([mutableParams objectForKey:@"method"] == nil) {
NSLog(@"API Method must be specified");
return nil;
}
- NSString * methodName = [params objectForKey:@"method"];
- [params removeObjectForKey:@"method"];
+ NSString * methodName = [mutableParams objectForKey:@"method"];
+ [mutableParams removeObjectForKey:@"method"];
return [self requestWithMethodName:methodName
- andParams:params
+ andParams:mutableParams
andHttpMethod:@"GET"
andDelegate:delegate];
}
@@ -551,7 +553,7 @@ - (FBRequest*)requestWithParams:(NSMutableDictionary *)params
* Returns a pointer to the FBRequest object.
*/
- (FBRequest*)requestWithMethodName:(NSString *)methodName
- andParams:(NSMutableDictionary *)params
+ andParams:(NSDictionary *)params
andHttpMethod:(NSString *)httpMethod
andDelegate:(id <FBRequestDelegate>)delegate {
NSString * fullURL = [kRestserverBaseURL stringByAppendingString:methodName];
@@ -608,7 +610,7 @@ - (FBRequest*)requestWithGraphPath:(NSString *)graphPath
* Returns a pointer to the FBRequest object.
*/
- (FBRequest*)requestWithGraphPath:(NSString *)graphPath
- andParams:(NSMutableDictionary *)params
+ andParams:(NSDictionary *)params
andDelegate:(id <FBRequestDelegate>)delegate {
return [self requestWithGraphPath:graphPath
@@ -647,7 +649,7 @@ - (FBRequest*)requestWithGraphPath:(NSString *)graphPath
* Returns a pointer to the FBRequest object.
*/
- (FBRequest*)requestWithGraphPath:(NSString *)graphPath
- andParams:(NSMutableDictionary *)params
+ andParams:(NSDictionary *)params
andHttpMethod:(NSString *)httpMethod
andDelegate:(id <FBRequestDelegate>)delegate {
@@ -687,23 +689,25 @@ - (void)dialog:(NSString *)action
* dialog has completed.
*/
- (void)dialog:(NSString *)action
- andParams:(NSMutableDictionary *)params
+ andParams:(NSDictionary *)params
andDelegate:(id <FBDialogDelegate>)delegate {
+ NSMutableDictionary *mutableParams = [params copy];
+
[_fbDialog release];
NSString *dialogURL = [kDialogBaseURL stringByAppendingString:action];
- [params setObject:@"touch" forKey:@"display"];
- [params setObject:kSDKVersion forKey:@"sdk"];
- [params setObject:kRedirectURL forKey:@"redirect_uri"];
+ [mutableParams setObject:@"touch" forKey:@"display"];
+ [mutableParams setObject:kSDKVersion forKey:@"sdk"];
+ [mutableParams setObject:kRedirectURL forKey:@"redirect_uri"];
if ([action isEqualToString:kLogin]) {
- [params setObject:@"user_agent" forKey:@"type"];
- _fbDialog = [[FBLoginDialog alloc] initWithURL:dialogURL loginParams:params delegate:self];
+ [mutableParams setObject:@"user_agent" forKey:@"type"];
+ _fbDialog = [[FBLoginDialog alloc] initWithURL:dialogURL loginParams:mutableParams delegate:self];
} else {
- [params setObject:_appId forKey:@"app_id"];
+ [mutableParams setObject:_appId forKey:@"app_id"];
if ([self isSessionValid]) {
- [params setValue:[self.accessToken stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
+ [mutableParams setValue:[self.accessToken stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
forKey:@"access_token"];
[self extendAccessTokenIfNeeded];
}
@@ -717,13 +721,13 @@ - (void)dialog:(NSString *)action
if (self.isFrictionlessRequestsEnabled) {
// 1. show the "Don't show this again for these friends" checkbox
// 2. if the developer is sending a targeted request, then skip the loading screen
- [params setValue:@"1" forKey:@"frictionless"];
+ [mutableParams setValue:@"1" forKey:@"frictionless"];
// 3. request the frictionless recipient list encoded in the success url
- [params setValue:@"1" forKey:@"get_frictionless_recipients"];
+ [mutableParams setValue:@"1" forKey:@"get_frictionless_recipients"];
}
// set invisible if all recipients are enabled for frictionless requests
- id fbid = [params objectForKey:@"to"];
+ id fbid = [mutableParams objectForKey:@"to"];
if (fbid != nil) {
// if value parses as a json array expression get the list that way
SBJsonParser *parser = [[[SBJsonParser alloc] init] autorelease];
@@ -737,7 +741,7 @@ - (void)dialog:(NSString *)action
}
_fbDialog = [[FBDialog alloc] initWithURL:dialogURL
- params:params
+ params:mutableParams
isViewInvisible:invisible
frictionlessSettings:_frictionlessRequestSettings
delegate:delegate];
View
4 src/facebook-ios-sdk.xcodeproj/project.pbxproj
@@ -203,7 +203,7 @@
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0420;
+ LastUpgradeCheck = 0430;
};
buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "facebook-ios-sdk" */;
compatibilityVersion = "Xcode 3.2";
@@ -259,6 +259,7 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = facebook_ios_sdk_Prefix.pch;
+ GCC_THUMB_SUPPORT = NO;
INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)";
PRODUCT_NAME = facebook_ios_sdk;
PUBLIC_HEADERS_FOLDER_PATH = "$(TARGET_NAME)";
@@ -279,6 +280,7 @@
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = facebook_ios_sdk_Prefix.pch;
+ GCC_THUMB_SUPPORT = NO;
INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)";
PRODUCT_NAME = facebook_ios_sdk;
PUBLIC_HEADERS_FOLDER_PATH = "$(TARGET_NAME)";
Please sign in to comment.
Something went wrong with that request. Please try again.