2011-08-06 132 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