我试图通过以下代码发布到用户的朋友的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