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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:45:09+00:00 2026-05-23T17:45:09+00:00

Sorry for the newbie question, but i cannot find an answer to it. I

  • 0

Sorry for the newbie question, but i cannot find an answer to it.

I have a simple operation. I declare a variable, and then i want to loop through an array of integers and add these to the variable. However, i can’t seem to find how to get a += equivalent going in Objective C.

Any help would be awesome.

Code:

NSInteger * result;
for (NSInteger * hour in totalhours)
{
    result += hour; 
}
  • 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-23T17:45:11+00:00Added an answer on May 23, 2026 at 5:45 pm

    NSInteger is not a class, it’s a typedef for int. You cannot put it into collections like NSArray directly.

    You need to wrap your basic data types (int, char, BOOL, NSInteger (which expands to int)) into NSNumber objects to put them into collections.

    NSInteger does work with +=, keep in mind that your code uses pointers to them, which is probably not what you want anyway here.

    So

    NSInteger a = 1, b = 2; 
    a += b; 
    

    would work.

    If you put them with [NSNumber numberWitInt:a]; etc. into an NSArray, this is not that easy and you need to use -intValue methods to extract their values first.

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

Sidebar

Related Questions

Sorry for the extreme newbie question, but I couldn't find the answer elsewhere and
sorry for the newbie question but, I'm new to programming.. I want to check
Sorry for this newbie question but I cannot figure how I can do this..
Sorry for this newbie question, just got starting. I want a simple program to
Sorry for this lame question, but I really am a database newbie: I want
I'm sorry for this newbie question, but I need a quick answer to tell
Sorry for the dummy question but I'm a regular expressions newbie. I want these
Sorry for this newbie question, but I can't find on google what I need
Sorry if this is a newbie question. I have searched but found nothing... Using
sorry for a newbie question.. but Service by it's defenision meaning the same as

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.