isEqualToString can the items be swapped?
I am just curious if there is a way to swap the two stings in this example?
// This works
for(eachArtist in artistCollection) {
if([objFirName isEqualToString: [eachArtis开发者_如何学JAVAt firName]]) NSLog(@"DELETE ....");
}
What I was trying to do was (see below) can this be done or is the above the only way?
[eachArtist firName isEqualToString: objFirName]
eachArtist.firName is a NSString within an array of objects, objFirName is a vanilla NSString.
gary
If you have synthesized the firName
property in the Artist
implementation, the two approaches are equivalent.
That is:
[eachArtist firName]
is the same as
eachArtist.firName
If the @property
is @synthesize
-d in Artist.m
and readwrite
or readonly
in Artist.h
.
Since you are performing an isEqualToString
predicate and not a less-than or greater-than predicate, it doesn't matter the order in which elements are in the predicate.
In mathematical terms, A = B if and only if B = A, for the purposes of comparing strings.
精彩评论