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 9164263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:38:24+00:00 2026-06-17T14:38:24+00:00

Im haveing a problem suming two NSInteger, I have tried with simple int but

  • 0

Im haveing a problem suming two NSInteger, I have tried with simple int but cant find the answer. I Have this on my header file:

@interface ViewController : UIViewController {
NSMutableArray *welcomePhotos;
NSInteger *photoCount;        // <- this is the number with the problem
//static int photoCount = 1;
}

The on my implementation fiel I have:

-(void)viewDidLoad{
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

    photoCount = 0;
    welcomePhotos = [NSMutableArray array];


    int sum = photoCount + 1;

    NSLog(@"0 + 1 = %i", sum);

}

The las NSLog always prints 0 + 1 = 4

Also if if do:

if (photoCount < [welcomePhotos count]){
    photoCount++;
    NSLog(@"%i", photoCount);
}else{
    photoCount = 0;
}

Several times i get: 4, 8, 12.

So it is skiping by four, but I can’t get to understand why.

  • 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-17T14:38:26+00:00Added an answer on June 17, 2026 at 2:38 pm

    You’re printing out a pointer object I believe as you’ve declared it as

    NSInteger* photocount;
    

    Try changing it to

    int photocount;
    

    doing a variable++ on an integer adds the size of a pointer which is 4 bytes on iOS.

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

Sidebar

Related Questions

Im having problem in my UIscrollView ,this is what I have done: Whenever a
I am having problem to get a numerical value for this expression where I
I'm having problem with datagrid view. I have attached an image with the code
hello I am having problem related to https:// . I have used FB.getLoginStatus(function(response) function
i am haveing some problems with JSON and arrays. I have been messing around
my sql statement is something like this below DECLARE @OLD_NAV_VALUE AS INT DECLARE @FINAL
Having problem with this bit of code qith jQuery. it should pick the values
im having problem whith a POST request. I have to receive an XML message
I having problem to update the counter (integer value). this is the definitions of
m having problem in passing parameter to controller action, i have done the following

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.