vendredi 22 juillet 2016

Convert uint64_t to NSNumber

Code below:

- (id)initWithMediaCollection:(MPMediaItemCollection *)mediaCollection collectionCategory:(NSString *)collectionCategory
{
    self = [super init];
    if (self) {
        _mediaCollection = mediaCollection;
        uint64_t persistentID = mediaCollection.persistentID;
        _collectionID = [NSNumber numberWithUnsignedLongLong:persistentID];
    }
    return self;
}

I debug and then set a breakpoint. The first time this init method gets run, it works fine:

persistentID uint64_t 6071794744315787357

_collectionID __NSCFNumber * (long)6071794744315787357

The second time, I get these values:

persistentID uint64_t 14938043870126423662

_collectionID __NSCFNumber * (long)-3508700203583127954

Why aren't the values the same the second time around? Why is it negative when I explicitly declared it as unsigned?

Aucun commentaire:

Enregistrer un commentaire