Ios 使用graph api在facebook上发布高分
编辑:10-9-10Ios 使用graph api在facebook上发布高分,ios,facebook,facebook-graph-api,Ios,Facebook,Facebook Graph Api,编辑:10-9-10 我认为当JSON库试图解析 [NSString stringWithFormat:@"%d weeks",[components week]]; 我将如何格式化它以便JSON能够解析它 下面是JSON代码行 NSString *attachmentStr = [jsonWriter stringWithObject:attachment]; NSMutableDictionary* params = [NSMutableDictionary dicti
我认为当JSON库试图解析
[NSString stringWithFormat:@"%d weeks",[components week]];
我将如何格式化它以便JSON能够解析它
下面是JSON代码行
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
kAppId, @"api_key",
@"Share on Facebook", @"user_message_prompt",
actionLinksStr, @"action_links",
attachmentStr, @"attachment",
nil];
有人能给我指一个关于如何做到这一点的教程吗?我可以轻松地在下面的代码块中发布静态文本,但我无法将NSString
与动态数据集成,它不会显示在Fb post附件部分
NSDictionary *attachment = [NSDictionary dictionaryWithObjectsAndKeys:
@"Testing", @"name",
@"testing2", @"caption",
[NSString stringWithFormat:@"%d weeks",[components week]], @"description"//Xcode says components undeclared
//highscore, @"description", //here's the problem, highscore is the NSString variable.
@"http://testing.com/", @"href", nil];
更新:
问题是,我使用的字符串来自两周的时间间隔,输出是[components week]
,然后xcode告诉我components是一个未声明的变量
[NSString stringWithFormat:@"%d weeks",[components week]]
下面是我从中获取上述字符串的整个日期代码块:
NSString *dateStr = @"20100716";
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyyMMdd"];
NSDate *startDate = [dateFormat dateFromString:dateStr];
NSDate *endDate = [NSDate date];
NSCalendar *gregorian = [[NSCalendar alloc]
initWithCalendarIdentifier:NSGregorianCalendar];
NSUInteger unitFlags = NSWeekCalendarUnit | NSDayCalendarUnit;
NSDateComponents *components = [gregorian components:unitFlags
fromDate:startDate
toDate:endDate options:0];
NSInteger weeks = [components week];
NSInteger days = [components day];
尝试stringWithFormat
[NSString stringWithFormat:@“%@”,高分]代码>而不是高分