开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜