I’ve come across a strange problem. If I run the following code, I get my Tweet box text as “Today I have listened to (null)”. And when I changed str1 in the [tweet setInitialText:str1]; to txt1.text the code won’t run and I get this message “Too many arguments to method call expected 1 have 2”.
Am I missing something?
Thanks in advance.
@implementation ViewController
@synthesize txt1;
-(IBAction)Twitte{
if ([TWTweetComposeViewController canSendTweet]){
NSString *str1 = [[NSString alloc] initWithFormat:@"Today I have listened to %@", txt1.text];
TWTweetComposeViewController *tweet = [[TWTweetComposeViewController alloc] init];
[tweet setInitialText:str1];
[tweet addURL:[NSURL URLWithString:@"http://twitter.com/#!/"]];
[self presentModalViewController:tweet animated:YES];
}
The IBAction expects an id param. The null in the string means that the txt1 is nil. It can’t answer a string because it doesn’t point to anything. Add a param and check where you initialize txt1.