pointer before declaration of object objective-c
can you tell me something : is it a mistake or can we write "result" without the " * " here :
@implementation Person (Sorting)
- (NSComparisonResult)compareByName:(Person *)person2 {
>>//here :
>>NSComparisonResult result = [self.lastN开发者_运维百科ame caseInsensitiveCompare:person2.lastName];
if (result == NSOrderedSame) {
return [self.firstName caseInsensitiveCompare:person2.firstName];
}
return result;
}
@end
Thanks
caseInsensitiveCompare
method returns NSComparisonResult
so not using * is absolutely correct.
In objective-c you must use pointers to obj-c objects, but NSComparisonResult
is just an enum (i.e. plain integer) so you may freely use it without pointer.
精彩评论