我正在使用Xcode 4.6.1为iOS 6开发。
我有两个视图控制器:viewController1
和viewController2
。我正在尝试访问viewController1
中viewController2
中定义的属性,如下所示(但它不起作用):
这是viewController1.m
:
#import "viewController1.h"
@interface viewController1 ()
@property (nonatomic) MPMoviePlayerController *videoPlayer;
@end
@implementation viewController1
...
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
...
self.videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
...
[self.videoPlayer play];
...
}
这是viewController2.m
:
#import "viewController2.h"
#import "viewController1.h"
@interface viewController2 ()
@end
@implementation viewController2
...
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
viewController1 *thePlayer;
[thePlayer.videoPlayer pause];
//This is where I get an error:
//Property 'videoPlayer' not found on object of type 'viewController1 *'
}
我尝试了很多搜索,但我无法弄清楚我做错了什么。任何帮助都将受到高度赞赏。
谢谢! :)
答案 0 :(得分:3)
您已在videoPlayer
中定义了viewController1.m
属性,但导入了viewController1.h
。
将videoPlayer
移至viewController1.h
。请勿导入viewController1.m
。