Wednesday, March 23, 2011

Request for member 'item' in something not a structure or union

There are several ways how you can get this compiler error - and here's another one. With one way to fix it.

First setup everything:
@interface MyPlayer : MPMoviePlayerViewController
{
UIView *parentView;
}
@property (nonatomic, retain) UIView *parentView;
@end

@interface MyView : UIView
{
MyPlayer *myPlayer;
}
@end
This doesn't work, compiler error:
self.myPlayer = [[MyPlayer alloc] init];
self.myPlayer.parentView = self;
This is ok:
MyPlayer *player = [[MyPlayer alloc] init];
player.parentView = self;
self.myPlayer = player;
[player release];
Divide and conquer... If this didn't help you, remember to check that you import correct header files.

No comments:

Post a Comment