2012-07-25 46 views
1

我试图通过以下代码发布到用户的朋友的FB墙。我卡在这一行:** NSString * post = [[delegate.array objectAtIndex:tag.tag] objectForKey:@“id”];如何解决没有在类型“AppDelegate”类型的对象上找到的属性数组错误

**
出现错误消息:“属性阵列类型的对象未找到‘的AppDelegate’

AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; 

     //Call the request method 
     [[delegate facebook] requestWithGraphPath:@"me/friends" andDelegate:self]; 


     // get the array of friends     
     NSArray *data = [result objectForKey:@"data"]; 

     // Check that the user has friends 
     if ([data count] > 0) { 

      NSMutableArray *array = [NSMutableArray array];  
      for (int i = 0; i < data.count; i++){ 
       id object = [data objectAtIndex:i]; 
       [array addObject:[object objectForKey:@"name"]]; 
      } 

      NSLog(@"list of friends %@", array); 

      NSString *Message = [NSString stringWithFormat:@"-posted via iPhone App"]; 
      NSMutableDictionary *params1 = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
              Message, @"message", nil]; 
      NSString *post=[[delegate.array objectAtIndex:tag.tag] objectForKey:@"id"]; 

      [[delegate facebook] requestWithGraphPath:[NSString stringWithFormat:@"/%@/feed",post] andParams:params1 andHttpMethod:@"POST" andDelegate:self]; 

      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Message!" message:@"Message Sent" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
      [alert show]; 
      [alert release]; 
+1

看看你AppDelegate.h,应该有一个声明的属性'NSArray的* array'那里,如果缺少,添加它。和综合您的执行 – janusbalatbat 2012-07-25 10:07:51

+0

谢谢。解决了数组警告。那么NSString * post = [[delegate.array objectAtIndex:tag.tag] objectForKey:@“id”];我现在正在获取未声明的标识符'标记'。谢谢 – hanumanDev 2012-07-25 10:18:45

+0

你也有两个数组叫做数组。我会建议为它们命名一些更有用的东西 – Dan 2012-07-25 10:19:41

回答

1

历时3天,我知道你有在iphone获取Facebook好友的问题,所以我做。为你的演示。希望你喜欢这个。:)

Fetch Facebook friend here

+0

大声笑。肯定是一个大问题!感谢您的帮助:) – hanumanDev 2012-07-25 10:41:17

+0

如果您有问题发布在用户墙上告诉我,我会帮助你currenty我不打电话thsi功能在演示,但我写的代码已经,你只是叫它 – 2012-07-25 10:51:36

+0

非常感谢!我遇到的问题是这段代码挑选了一个随机的朋友:kAPIFriendsForDialogFeed: { NSArray * resultData = [result objectForKey:@“data”]; //检查用户是否有朋友 if([resultData count]> 0){ //选取一个随机朋友将提要张贴到 int randomNumber = arc4random()%[resultData count]; [self apiDialogFeedFriend:[[resultData objectAtIndex:randomNumber] objectForKey:@“id”]]; } else { [self showMessage:@“你没有任何朋友可以发帖。”]; } – hanumanDev 2012-07-25 11:20:03