-6

以下のコードのようなフレンドリストの詳細が欲しい

if (FBSession.activeSession.isOpen) {
    [[FBRequest requestForMyFriends] startWithCompletionHandler:
     ^(FBRequestConnection *connection,
       NSDictionary<FBGraphUser> *user,
       NSError *error) {
         if (!error) {
            NSString *friendnames=[NSString stringWithFormat:@"Hello %@!", user.friendsnames];
         }}];

}

誰でもこのコードを手伝ってもらえますか?

4

1 に答える 1

6

私のアプリでは、私はこのようにやっています:

[self.facebook requestWithGraphPath:@"me/friends?fields=name,picture,installed" andDelegate:self];

if ([request.url hasSuffix:@"me/friends?fields=name,picture,installed"])
{
    NSMutableArray *array = [NSMutableArray array];
    for (NSDictionary *dict in [result objectForKey:@"data"])
    {
        FacebookUser *friend = [[FacebookUser alloc] initWithDictionary:dict];
        [array addObject:friend];
    }
    NSLog(@"%@", result);

お役に立てば幸いです、 マリオ

編集:

これは私が作成したモデルで、NSObject を実装しています

FacebookUser.h

#import <Foundation/Foundation.h>

@interface FacebookUser : NSObject

@property (readonly) NSString *facebookID;
@property (readonly) NSURL *link;
@property (readonly) NSString *name;
@property (readonly) NSString *pictureURL;
@property (readonly) NSString *firstName;
@property (readonly) NSString *lastName;

FacebookUser.m

#import "FacebookUser.h"

@implementation FacebookUser

@synthesize facebookID = _facebookID;
@synthesize link = _link;
@synthesize name = _name;
@synthesize pictureURL = _pictureURL;
@synthesize firstName = _firstName;
@synthesize lastName = _lastName;

- (id)initWithDictionary:(NSDictionary *)dictionary;
{
    self = [super init];
    if (self)
    {
    _facebookID = [dictionary valueForKey:@"id"];

    //IMPLEMENT WHAT YOU WANT TO SAVE.... 

    }

    return self;
}  

@end
于 2012-09-07T11:19:46.327 に答える