0

我是一名初级软件开发人员,我可以将 (unsigned) 更改为 (NSUInteger) 还是稍后会产生问题?

- (unsigned)retainCount
{
    return UINT_MAX;  //denotes an object that cannot be released
}

警告说

MKStoreManager.m:88:1: Conflicting return type in implementation of 'retainCount': 'NSUInteger' (aka 'unsigned long') vs 'unsigned int'

我找到了以前的定义

- (NSUInteger)retainCount OBJC_ARC_UNAVAILABLE;
4

1 回答 1

2

您的方法必须返回NSUInteger,因为这就是retainCount方法在NSObject.

该错误是由您尝试返回的值引起的。而不是返回UINT_MAX,你应该返回NSUIntegerMax

基础类型的NSUInteger变化取决于构建 32 位还是 64 位。因此, 的值NSUIntegerMax也会更改以匹配类型。

- (NSUInteger)retainCount
{
    return NSUIntegerMax;  //denotes an object that cannot be released
}
于 2015-07-14T15:48:33.447 回答