0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

(iOS Objective-C) ViewControllerのインスタンス変数にself.propでアクセス時に「Property not found on object of type ViewController」と出る

Posted at

■問題:ViewControllerのインスタンス変数にself.propでアクセス時に「Property not found on object of type ViewController」と出る

下記のリンクと同じような状況で、ViewControllerのインスタンス変数にself.propでアクセス時に「Property not found on object of type ViewController」と出る状況でした。

@interface ViewController() {
    AVPlayer *player;
}
@end

@implementation ViewController
- (void) viwDidLoad {
    self.player = [AVPlayer alloc];  // エラー発生
}

■解決法:property の宣言方法

リンクを参考にして、@property (nonatomic, assign) を使用するとエラーが消えました。

@interface ViewController();

@property (nonatomic, assign) AVPlayer *player;

@end

@implementation ViewController
- (void) viwDidLoad {
    self.player = [AVPlayer alloc];  // ビルドが通る
}

以上です。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?