iosobjective-cunsignednsuinteger

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


I am a Jr Software Developer, can I just change the (unsigned) to (NSUInteger) or will to create problems later?

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

warning said

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

I found a previous definition

- (NSUInteger)retainCount OBJC_ARC_UNAVAILABLE;

Solution

  • Your method must return NSUInteger because that is how the retainCount method is defined in NSObject.

    The error is being caused by the value you are trying to return. Instead of returning UINT_MAX, you should return NSUIntegerMax.

    The underlying type for NSUInteger changes depending on whether building for 32 or 64 bit. Accordingly, the value of NSUIntegerMax also changes to match the type.

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