我試圖通過以下代碼發佈到用戶的朋友的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];
看看你AppDelegate.h,應該有一個聲明的屬性'NSArray的* array'那裏,如果缺少,添加它。和綜合您的執行 – janusbalatbat 2012-07-25 10:07:51
謝謝。解決了數組警告。那麼NSString * post = [[delegate.array objectAtIndex:tag.tag] objectForKey:@「id」];我現在正在獲取未聲明的標識符'標記'。謝謝 – hanumanDev 2012-07-25 10:18:45
你也有兩個數組叫做數組。我會建議爲它們命名一些更有用的東西 – Dan 2012-07-25 10:19:41