我有一个名为boxView.h / m的类,另一个名为TileView.h / m
#import <UIKit/UIKit.h>
#import "TileView.h"
@interface BoxView : UIView {
}
- (void) addCurrentTile: (TileView*)aTile;
@end
.m文件中有一个方法:
-(void) addCurrentTile: (TileView*)aTile{
[currentTurnTilesArray addObject:aTile];
}
在TileView.m中,我需要调用addCurrentTile。目前这似乎有效,但我收到警告说'UIView' may not respond to 'addCurrentTile:'
#import "TileView.h"
#import "BoxView.h"
@implementation TileView
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[image setImage:[UIImage imageNamed:@"tileflipped.png"]];
[self.superview addCurrentTile:self];
}
我试图阅读并了解更多关于从不同类中调用方法的知识,但我似乎无法将此警告消失。想法?
答案 0 :(得分:1)
使用演员:
[(BoxView *)self.superview addCurrentTile:self];