Search code examples
iphonexcodeios5twitter

Too many arguments to method call, expected 1, have 2


I am using TWTweetComposeViewController for iOS 5 legacy in my app. For some reason, I am receiving a "Too many arguments to method call, expected 1, have 2" error." I have tried looking for answers in similar questions, but they haven't helped me so far.

Here is the code:

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

Any ideas? Thanks in advance.

Screenshot


Solution

  • Like the error says, you have too many arguments. You need to use NSString's stringWithFormat method to create your dynamic string:

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