What you think is beautiful. To the extent that you know the types, specify them so that they are clear with the compiler and people reading the code in the future. Also use isEqualToString: to compare strings.
for (Foo *foo in myFooCollection) {
for (Bar *bar in myBarCollection) {
if ([foo.name isEqualToString:bar.name]) {
}
}
}
, , - : Foo, Bar.
- (NSComparisonResult)compare:(id)otherObject {
if ([otherObject isKindOfClass:[Bar self]]) {
Bar *itsABar = (Bar *)otherObject;
return [self.name compare:itsABar.name];
}
return [super compare:otherObject];
}
.