RGriffiths
RGriffiths

Reputation: 5970

Data being drawn from core data is incorrect

I have an app that stores data using core data. At one point data is retrieved and I can't seem to get it right. I am trying to get the value -5 as from the field ObsObservationResult.

In the sqlite browser I see this:

enter image description here

The value is stored as -5. The data from core data is retrieved using:

NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Observations"];
NSError *error = nil;
observationList = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];

And

    NSUInteger obsResult = [[[observationList objectAtIndex:loop1] valueForKey: @"obsObservationResult"] integerValue];

sets ObsResult but when I look at the actual value retrieved I get something odd.

enter image description here

I have no idea why it does not show -5 as it id in the sqlite database.

Upvotes: 0

Views: 24

Answers (1)

Joe
Joe

Reputation: 57179

NSUInteger is an unsigned integer which does not support negative numbers. Use NSInteger instead. What you are seeing is the NSUInteger representation of -5.

Upvotes: 1

Related Questions