Implicit conversion of an Objective-C to 'NSUInteger *' (aka 'unsigned int *') is dis

Discussion in 'Mac Programming' started by johnmerlino, Nov 10, 2011.

  1. macrumors member

    Joined:
    Oct 22, 2011
    #1
    Hey all,

    I get his message:

    Implicit conversion of an Objective-C to 'NSUInteger *' (aka 'unsigned int *') is disallowed with ARC

    with this line right here:

    Unit *unit = [[Unit alloc] init];
    unit.unit_id = [dict objectForKey:mad:"id"];

    THis is the header:

    Code:
    @interface Unit : NSObject
    {
        @private
        NSString *name;
        NSUInteger *unit_id;
    }
    @property (weak, nonatomic)  NSString *name;
    @property (assign, nonatomic)  NSUInteger *unit_id;
    
    
    @end
    
    This is the implementation:

    Code:
    #import "Unit.h"
    
    @implementation Unit
    @synthesize name = _name;
    @synthesize unit_id;
    
    @end
    
    Not sure why the error occurs and what it is exactly trying to say.

    Thanks for response
     
  2. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    #2
    It's telling you that your code is badly wrong.
    Whatever is in a dictionary cannot be an NSUInteger*.

    So either you messed up when you tried to put an NSUInteger* into a dictionary, or you are messing up when you try to store a pointer to an NSObject into an NSUInteger*.
     
  3. macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #3
    You're confused about what an NSUInteger is. It is not an NSObject, like NSNumber. It is typedef'd to a primitive value. This means it can't be used in containers that require an NSObject, and you would normally not need a pointer to one (there are reasons, this is not one). If you need a number that's an NSObject, try NSNumber.

    -Lee
     

Share This Page