Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8086639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:30:58+00:00 2026-06-05T18:30:58+00:00

this is the code: NSNumber *taskId = [[self.taskList objectAtIndex:indexPath.row] valueForKey:@identity]; NSInteger *intTaskId = [[self.taskList

  • 0

this is the code:

NSNumber *taskId = [[self.taskList objectAtIndex:indexPath.row] valueForKey:@"identity"];    
NSInteger *intTaskId = [[self.taskList objectAtIndex:indexPath.row] valueForKey:@"identity"];

self.taskList is an NSArray which filled with core data fetch request in ViewController’s viewDidLoad method.
the taskId is: 1
the intTaskId is: 269303816
In actually, the value stored in core data is: 1

below is my questions:
1, I am confused why the NSInteger incorrect?
2, Should I have to replace NSInteger with NSNumber to avoid any other problems?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:31:00+00:00Added an answer on June 5, 2026 at 6:31 pm

    NSNumber is an object, whereas NSInteger is simply a typedef for a primitive (non-object) type (like int). NSInteger is not a subclass of NSNumber. Core Data returns numbers as instances of NSNumber. You’re getting the weird NSInteger value because it’s pointing to an object of type NSNumber but attempting to print it as if it were just an integer.

    You’ll need to replace NSInteger with NSNumber to avoid any problems. You could also use the intValue method on NSNumber to get back an NSInteger:

    NSNumber *objTaskId = [[self.taskList objectAtIndex:indexPath.row] valueForKey:@"identity"];
    NSInteger *intTaskId = [objTaskId intValue];
    

    You’ll need to do this if you want to do comparisons (greater than, equal too, smaller than) or arithmetic (you can’t add an NSNumber to another NSNumber or an NSNumber to a primitive type like an int or float).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I solve this problem? code: [NSNumber numberWithInteger:[buttonStatsInSection objectAtIndex:row]] warning: passing argument 1
I have a question related to this piece of code NSNumber *lastObject = [self.myStack
This code works: monkey.h @interface monkey : NSObject { NSNumber *monkeyRanch; } @property (nonatomic,
I am using this code for cellForRowAtIndexPath: -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if
I've found this code snippet: [self setValue:direction forKey:@currentDirection]; CAKeyframeAnimation * animation = [CAKeyframeAnimation animationWithKeyPath:@position];
I have this code: NSNumber *num; NSAutoreleasePool *apool = [[NSAutoreleasePool alloc] init]; for (int
I have this code: -(void)startRotation:(RDUtilitiesBarRotation)mode { rotationTimer = [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(rotateSelectedItem:) userInfo:[NSNumber numberWithInt:mode]
my partial code to store location with image. CLLocation *location = self.filteredLocation ; NSNumber
So, I have this code: timer = [NSTimer scheduledTimerWithTimeInterval:4.0 target:self selector:@selector(a) userInfo:nil repeats:YES]; This
I am executing this code: NSLog(@Converting line number %@ to int...,currentValue); NSNumber * currentNumber

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.