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

  • Home
  • SEARCH
  • 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 6691823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:47:49+00:00 2026-05-26T05:47:49+00:00

I have an NSInteger in my class like so In @interface: NSInteger currentRow; @property

  • 0

I have an NSInteger in my class like so

In @interface:

NSInteger currentRow;    

@property (assign) NSInteger currentRow;

In @implementation:

@synthesize currentRow;

Doing [self setCurrentRow:0] seems to work fine, but using [self currentRow] just returns null for some reason, not sure why. When using breakpoints I can see that the value for currentRow is 0 so it has set fine, but I can’t get the value back.

  • 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-05-26T05:47:49+00:00Added an answer on May 26, 2026 at 5:47 am

    In Objective-C, it’s important that you distinguish between objects and primitive types.

    An object is always stored as a pointer, which is the object’s location in memory. A pointer is just a number. With NSLog, you can use %p to see this value. You can display it in the debugger too, like this: print myObject. A pointer is displayed as a hexadecimal number, with a 0x prefix. nil is essentially location zero (0x0000). When you allocate any kind of object, you’ll get a pointer which isn’t zero. When you assign an object to a variable, you are simply copying the memory address, not duplicating the object. With NSLog, you can use %@ to print out an object’s description. In the debugger, like this: print-object myObject.

    Primitive types like NSInteger aren’t objects. Instead of storing a pointer, usually you just store the value. When you assign an NSInteger variable, you make a copy of the value. You can see the value in the debugger using print. Or like this: NSLog("%ld", (long)currentRow). When you assign a primitive, you copy its value. Don’t use %@ or print-object with primitives — they expect objects.

    (I say “usually you just store the value,” because you can make pointers to primitive types, too. In situations like yours however it’s not necessary.)

    [self currentRow] returns 0, just like you set it. (Furthermore, because Objective-C guarantees initialization of instance variables, it’ll return 0 even if you don’t set it.)

    The problem is that you’re expecting a pointer to an object. How you fix your code depends on how you’re using it:

    • If you’re using print-object currentRow, change it to print currentRow.
    • If you’re using NSLog("%@", currentRow), change it to NSLog(%"ld", (long)currentRow).
    • If you’re using currentRow somewhere else, where an object is required, change your instance variable and property types to NSNumber *, an object type. Set it with [self setCurrentRow:[NSNumber numberWithInt:0]].
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom class: @interface Player : NSObject { NSInteger mPlayerNo; } -(id)
I have an NSInteger property of a custom class called 'estimatedTime', now, in my
I have a class that has a method: -(NSInteger) getCityCountForState:(NSString *)state CityArray:(NSMutableArray *)cityArray {
I have these delegate method for a tableview inside a class: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
I am doing: NSString *path = [[self class] pathForDocumentWithName:@Alarms.plist]; NSArray *alarmDicts = [NSMutableArray arrayWithContentsOfFile:path];
So I have a class with a NSInteger in it and now I want
I have a NSMutableArray property in my AppDelegate called blocks. I would like to
I have a class named myClass that contains 3 NSInteger and I can't do
I have been trying to check whether an NSInteger is odd or even. I
I have an situation where I get an NSDecimal, and I need an NSInteger.

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.