How to print a NSInteger value from an NSManagedObject using NSLog

前端 未结 5 1310
北恋
北恋 2021-01-12 06:15

When I try to print an integer value to the console that is retrieved from an NSManagedObject, it displays a 6 or 8 digit value (the object ID?). However, if I use the debug

5条回答
  •  孤城傲影
    2021-01-12 06:46

    NSInteger is just an int:

    typedef int NSInteger;
    

    In your first line of code:

    NSInteger sequence = [[NSNumber numberWithInteger:(NSInteger)sequence] intValue];
    

    All you are doing is assigning sequence to itself, in a round about way. And since it's not initialized, it might be any random number.

提交回复
热议问题