Objective-C:编写一个智能的可重用比较函数

时间:2013-02-15 21:06:59

标签: objective-c compare

此代码位于卡类的实例中。它具有以下属性:self.shape,self.color。 otherCards NSArray充满了这个类的其他实例,它们也有相同的self.shape等......

但是我想制作一个适用于形状,颜色,数字等的比较方法。通过传递self.shape,它比较otherCards的self.shape,并通过传递self.color有它 比较otherCards

的self.color
[self attributesIsEqual:self.shape with attribute:otherCards] //Calling the method


- (BOOL)attributesIsEqual: (id)attribue with: (NSArray *)otherCards
{
    // Compare whatever (id) attribute to the same attribute in otherCards
}

0 个答案:

没有答案