- (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];
}
我已经导入了框架。但我不知道如何解决这个错误......我该怎么办?谢谢:))
答案 0 :(得分:0)
它被宣称为'theSong',而不是歌曲。您从未在.h中声明指向tweetTextView的指针,并且未在任何文件中定义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];
}