2012-07-25 23 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

相關問題