Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS 5 NSNumber Bug
    primarykey
    data
    text
    <p>I will become crazy with this bug ! I have this piece of code which works well on iOS 4.3</p> <pre><code>newRegistered.ticket_id = [NSNumber numberWithInt: [curRegistered objectForKey:@"ticket_id"] intValue]]; </code></pre> <p>If I do :</p> <pre><code>NSLog(@"ID before : %d, ID after : %d", [curRegistered objectForKey:@"ticket_id"] intValue], [newRegistered.ticket_id intValue]); </code></pre> <p>I Have on iOS 4.3 :</p> <blockquote> <p>ID before : 35459, ID after : 35459</p> </blockquote> <p>And on iOS 5.0 :</p> <blockquote> <p>ID before : 35459, ID after : -30077</p> </blockquote> <p>Please help ! Thank you for advance.</p> <p><strong>##EDIT :##</strong> I have investigated a bit more the problem. It seems the problem comes from assigning a NSNumber in CoreData. I should have specified that the piece of code above is used with CoreData (newRegistered is a NSManagedObject, and curRegistered is a NSDictionary containing JSON Data (only strings, never int or long...)).</p> <p>Here is the specific problem :</p> <pre><code>long long test = 789654; Registereds *a = [NSEntityDescription insertNewObjectForEntityForName:@"Registereds" inManagedObjectContext:self.managedObjectContext]; a.ticket_id = [NSNumber numberWithLongLong:test]; NSLog(@"%lld -&gt; %@", test, a.ticket_id); // Displays 789654 -&gt; 3222 on iOS 5 and 789654 -&gt; 789654 on iOS 4.3 NSNumber *ticket_id = [NSNumber numberWithLongLong:test]; NSLog(@"%lld -&gt; %@", test, ticket_id); // Displays 789654 -&gt; 789654 </code></pre> <p>So it seems the problem comes from the Registereds object (which is a NSManagedObject, like the newRegistered in the previous example). </p> <p>Do you have any idea why this happens? I have never seen something like that in more than 2 years of coding, this bug really makes me think I don't know how to code...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload