我可以将 (unsigned) 更改为 (NSUInteger) 还是会产生问题?

Can I change (unsigned) to (NSUInteger) or will it create problems?

我是一名初级软件开发人员,我可以将 (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;

您的方法必须 return NSUInteger 因为那是 retainCount 方法在 NSObject.

中定义的方式

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

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

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