2012-11-15 57 views
0

我使用TWTweetComposeViewController iOS 5遺留在我的應用程序。出於某種原因,我收到了"Too many arguments to method call, expected 1, have 2" error."我試圖尋找類似問題的答案,但迄今爲止他們還沒有幫助我。太多的方法調用參數,預計1,有2

下面是代碼:

TWTweetComposeViewController *tweetSheet = 
       [[TWTweetComposeViewController alloc] init]; 
       [tweetSheet setInitialText:@"%@", [[_items objectAtIndex:indexPath.row] objectForKey:@"redirect_url"]]; 
       [self presentModalViewController:tweetSheet animated:YES]; 

任何想法?提前致謝。

Screenshot

回答

5

就像錯誤說的那樣,你有太多的論點。您需要使用NSString的stringWithFormat方法來創建動態字符串:

[tweetSheet setInitialText:[NSString stringWithFormat:@"%@", [[_items objectAtIndex:indexPath.row] objectForKey:@"redirect_url"]]]; 
+0

啊!作品完美無瑕!非常感謝你。 :) – chrisjr

2

您需要使用[NSString stringWithFormat:@"%@",object];做出格式字符串。

+0

你的意思是這樣?: '[tweetSheet setInitialText:@ 「%@」,[的NSString stringWithFormat:@ 「%@」,[ _items objectAtIndex:indexPath.row] objectForKey:@「redirect_url」]]];' 因爲它仍然給我同樣的錯誤。 – chrisjr

相關問題