forked from facebook/facebook-ios-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
theRunAround demo app make a few new object to handle different request
- Loading branch information
Yujuan Bao
committed
Aug 5, 2010
1 parent
9cbd90d
commit 8732684
Showing
12 changed files
with
226 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2010 Facebook | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "FBConnect.h" | ||
|
||
@protocol FriendsRequestDelegate; | ||
|
||
@interface FriendsRequestResult : NSObject<FBRequestDelegate> { | ||
id<FriendsRequestDelegate> _friendsRequestDelegate; | ||
} | ||
|
||
- (id) initializeWithDelegate: (id<FriendsRequestDelegate>)delegate; | ||
|
||
@end | ||
|
||
@protocol FriendsRequestDelegate<NSObject> | ||
|
||
- (void)FriendsRequestCompleteWithFriendsInfo:(NSMutableArray *)friendsInfo; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 2010 Facebook | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import "FriendsRequestResult.h" | ||
|
||
|
||
@implementation FriendsRequestResult | ||
|
||
- (id) initializeWithDelegate:(id<FriendsRequestDelegate>)delegate { | ||
self = [super init]; | ||
_friendsRequestDelegate = [delegate retain]; | ||
return self; | ||
} | ||
|
||
/** | ||
* FBRequestDelegate | ||
*/ | ||
- (void)request:(FBRequest*)request didLoad:(id)result{ | ||
|
||
NSMutableArray *friendsInfo = [[[[NSMutableArray alloc] init] autorelease] retain]; | ||
for (NSDictionary *info in result) { | ||
NSString *friend_id = [NSString stringWithString:[[info objectForKey:@"uid"] stringValue]]; | ||
NSString *friend_name = nil; | ||
if ([info objectForKey:@"name"] != [NSNull null]) { | ||
friend_name = [NSString stringWithString:[info objectForKey:@"name"]]; | ||
} | ||
NSString *friend_pic = [info objectForKey:@"pic_square"]; | ||
NSString *friend_status = [info objectForKey:@"status"]; | ||
NSMutableDictionary *friend_info = [NSMutableDictionary dictionaryWithObjectsAndKeys: | ||
friend_id,@"uid", | ||
friend_name, @"name", | ||
friend_pic, @"pic", | ||
friend_status, @"status", | ||
nil]; | ||
[friendsInfo addObject:friend_info]; | ||
} | ||
|
||
|
||
[_friendsRequestDelegate FriendsRequestCompleteWithFriendsInfo:friendsInfo]; | ||
|
||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2010 Facebook | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "FBConnect.h" | ||
|
||
@protocol UserRequestDelegate; | ||
|
||
@interface UserRequestResult : NSObject<FBRequestDelegate> { | ||
id<UserRequestDelegate> _userRequestDelegate; | ||
} | ||
|
||
- (id) initializeWithDelegate: (id<UserRequestDelegate>)delegate; | ||
|
||
@end | ||
|
||
@protocol UserRequestDelegate<NSObject> | ||
|
||
- (void)userRequestCompleteWithUid:(NSString *)uid; | ||
|
||
- (void)userRequestFailed; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2010 Facebook | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import "UserRequestResult.h" | ||
|
||
|
||
@implementation UserRequestResult | ||
|
||
- (id) initializeWithDelegate:(id<UserRequestDelegate>)delegate { | ||
self = [super init]; | ||
_userRequestDelegate = [delegate retain]; | ||
return self; | ||
} | ||
|
||
|
||
/** | ||
* FBRequestDelegate | ||
*/ | ||
- (void)request:(FBRequest*)request didLoad:(id)result{ | ||
|
||
NSString *uid = [result objectForKey:@"id"]; | ||
[_userRequestDelegate userRequestCompleteWithUid:uid]; | ||
|
||
} | ||
|
||
|
||
- (void)request:(FBRequest*)request didFailWithError:(NSError*)error { | ||
NSLog(@"%@",[error localizedDescription]); | ||
[_userRequestDelegate userRequestFailed]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.