以下是在Facebook移动应用中实施的代码,以发布到用户的墙上。如何将值更改为发布墙中的Textview.text,而不是用户必须键入它。
- (IBAction)publishStream:(id)sender {
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys: @"Always Running", @"text", @"http://itsti.me/", @"href", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
@"a long run", @"name",
@"The Facebook Running app", @"caption",
@"it is fun", @"description",
@"http://itsti.me/", @"href", nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Share on Facebook", @"user_message_prompt",
actionLinksStr, @"action_links",
attachmentStr, @"attachment",
nil];
[_facebook dialog:@"feed" andParams:params andDelegate:self];
}
答案 0 :(得分:1)
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
nameTextField.text, @"name",
captionTextField.text, @"caption",
descriptionTextField.text, @"description",
hrefTextField.text, @"href", nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
我不确定您是否允许用户编辑所有这些内容,如果不是只需将您需要的内容更改为您定义的NSString。