如何从不同的类中调用此方法,因为我已经尝试过并且失败了,请参见代码
#import <Foundation/Foundation.h>
@interface Card : NSObject
@property (strong, nonatomic) NSString *contents;
@property (nonatomic, getter = isFaceUp)BOOL faceUp;
@property (nonatomic, getter = isUnplayable)BOOL unplayable;
-(int)match:(NSArray *)otherCards;
@end
M file
#import "Card.h"
@implementation Card
@synthesize contents;
-(int)match:(NSArray *)otherCards
{
int score = 0;
for (Card *card in otherCards) {
[card.contents isEqualToString:self.contents];
score =1;
}
return score;
}
@end
我试过了,但它不起作用
Card *card = [[Card alloc]init];
[card match:otherCards]
code completion is giving me this
[card match:(NSArray *)]
如果我用 otherCards 替换 (NSArray *) 它甚至不会把它捡起来我得到这个错误
使用未声明的标识符“otherCards”