2011-08-06 103 views
0

下面是在Facebook移动应用中实现的代码发布到用户的墙上。如何将值更改为发布墙中的Textview.text,而用户必须键入它。需要帮助才能理解这个Objective-C代码片段

- (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]; 
} 

回答

1
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys: 
         nameTextField.text, @"name", 
         captionTextField.text, @"caption", 
         descriptionTextField.text, @"description", 
         hrefTextField.text, @"href", nil]; 
NSString *attachmentStr = [jsonWriter stringWithObject:attachment]; 

我不知道,如果你允许用户编辑所有的人,如果不只是改变你需要一个NSString你定义的。

+0

我知道。我已经有了。上面的代码是示例的权利?我应该在哪里更改为TextView.text – Noob

+0

现在,你已经明确你想要什么了我将编辑我的答案 –

+0

我改变了这样的代码。发布墙仍然要求用户填写文本框。 的NSDictionary *附着= [NSDictionary的dictionaryWithObjectsAndKeys: @ “我的应用程式名”,@ “姓名”, @ “我的应用的标题”,@ “字幕”, TextView.text,@ “描述”, @“HTTP ://myurl.net“,@”href“,nil]; – Noob