Objective c:无法识别的选择器发送到实例
我知道这种问题反复出现,但我无法用我找到的任何答案解决我的问题:(。
我正在开发一个应用程序,我需要获取音频流。我决定与 MPMoviePlayer 一起使用,所以我这样做了:
#import "MediaPlayer/MediaPlayer.h"
@interface FirstViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
...
IBOutlet MPMoviePlayerViewController *theMovie;
...
}
...
@property (nonatomic, retain) MPMoviePlayerViewController *theMovie;
在实现中,我只是 @synthesize-d 它。
现在,每当我分配它并尝试访问它的成员或方法时,我都会收到这个该死的错误无法识别的选择器。 后的第一行发送到实例:(
self.theMovie = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:@"http://netvarp.kringvarp.fo:554/radio/16/playlist.m3u8"]];
self.theMovie.moviePlayer.controlStyle = MPMovieControlStyleNone;
...
是在 viewDidLoad 方法中)
。
self.theMovie.moviePlayer.controlStyle = MPMovieControlStyleNone;
初始化
这 它没有“self”,如果声明一个MPMoviePlayerController,我这两天都不知道我做错了什么!太尴尬了:(
任何帮助将不胜感激。
我忘了提及,目标操作系统> 3.0。在模拟器上一切正常,但在设备上则不行(iPhone 2G 和 iPhone 3G,均配备 IOS 3.1.3)
I know this kind of question is repeatedly floating around over and over, but i haven't been able to solve my problem with any answer i found :( .
I'm developing an application and i need to fetch audio stream. I decided to go with MPMoviePlayer, so i did this:
#import "MediaPlayer/MediaPlayer.h"
@interface FirstViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
...
IBOutlet MPMoviePlayerViewController *theMovie;
...
}
...
@property (nonatomic, retain) MPMoviePlayerViewController *theMovie;
and in the implementation, i've just @synthesize-d it.
And now, whenever I allocate it and try to access it's members or methods, I get this damn error unrecognized selector sent to instance on the first line after the initialization:
self.theMovie = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:@"http://netvarp.kringvarp.fo:554/radio/16/playlist.m3u8"]];
self.theMovie.moviePlayer.controlStyle = MPMovieControlStyleNone;
...
(this is in viewDidLoad method).
I get the error in this line:
self.theMovie.moviePlayer.controlStyle = MPMovieControlStyleNone;
or whatever i call after the initialization.
Same goes if I remove the IBOutlet, if i call it without 'self', if declare a MPMoviePlayerController. I can't figure out what i'm I doing wrong for 2 days! So embarrassing :(
Any help will be appreciated.
I forgot to mention, Target OS is > 3.0. Everything works okay on the simulator, but not on devices (iPhone 2G and iPhone 3G, both with IOS 3.1.3)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将需要发布崩溃输出。
无法识别的选择器
意味着您正在尝试调用不存在的东西,例如:如果您的控制器中不存在
doSomethingSpecial
,您将收到无法识别的选择器选择器发送到实例You will need to post the crash output.
unrecognized selector
means you are trying to call something that doesn't exist, for example:if
doSomethingSpecial
doesn't exist in your controller, you will receive the unrecognized selector sent to instance正如苹果文档所说:
controlStyle 仅在 iOS 3.2 及更高版本中可用。
我认为这可能是您的问题,因为此方法在您的 3.1.3 设备上不可用,但我猜它在模拟器上(4.2.1)。
As the Apple Documentations says:
controlStyle is only available in iOS 3.2 and later.
I think this could be your problem, since this method is not available on your 3.1.3 device, but It is on the simulator, I guess (4.2.1).