Ошибки с кодом, чтобы получить и вставить твит в настоящее время играет песню - PullRequest
0 голосов
/ 15 января 2012

The errors

- (IBAction)playingSong {
MPMediaItem *theSong = [[MPMusicPlayerController iPodMusicPlayer] nowPlayingItem];
NSString *theTitle   = [song valueForProperty:MPMediaItemPropertyTitle];
NSString *theArtist  = [song valueForProperty:MPMediaItemPropertyArtist];
NSString *nowPlaying = [NSString stringWithFormat:@"#NowPlaying %@ by %@", theTitle, theArtist];
tweetTextView.text = [NSString stringWithFormat:@"%@%@", nowPlaying, tweetTextView.text];
[self setChars];
}

- (IBAction)sendMusicTweet:(id)sender {
    TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init];
    [tweetViewController setInitialText:tweetTextView.text];
    [self presentModalViewController:tweetViewController animated:YES];

}

Я импортировал фреймворки.Но я не знаю, как решить эту ошибку ... Что я могу сделать?Спасибо:)

1 Ответ

0 голосов
/ 15 января 2012

Он объявлен как «песня», а не как песня. Вы никогда не объявляли указатель на tweetTextView в .h, а setChars не определен в ЛЮБОМ файле.

Ваш код ДОЛЖЕН БЫТЬ:

- (IBAction)playingSong {
MPMediaItem *theSong = [[MPMusicPlayerController iPodMusicPlayer] nowPlayingItem];
NSString *theTitle   = [theSong valueForProperty:MPMediaItemPropertyTitle];
NSString *theArtist  = [theSong valueForProperty:MPMediaItemPropertyArtist];
NSString *nowPlaying = [NSString stringWithFormat:@"#NowPlaying %@ by %@", theTitle, theArtist];
//Declare tweetTextView in the .h!!
tweetTextView.text = [NSString stringWithFormat:@"%@%@", nowPlaying, tweetTextView.text];
//[self setChars]; Define this In the .h!
}

- (IBAction)sendMusicTweet:(id)sender {
    TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init];
    [tweetViewController setInitialText:tweetTextView.text];
    [self presentModalViewController:tweetViewController animated:YES];

}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...