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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:43:14+00:00 2026-05-11T13:43:14+00:00

I need to keep track of rows in sections in my UITableView. For this

  • 0

I need to keep track of rows in sections in my UITableView. For this I want to create an array in which I put an amount of rows in each section. This array should be of a certain size – so I suppose it would be better to use NSArray instead of NSMutableArray.

My question is – how can I initialize it with a certain number of objects of type NSInteger initially set to 0? And how can I alter that array – in my particular case to increase value of each item when I need it?

For instance:

while (objects) {  myArray.(object string's first letter transformed to int)++; } 
  • 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. 2026-05-11T13:43:14+00:00Added an answer on May 11, 2026 at 1:43 pm

    If the array is a specific size and all regular integers (NSInteger in your example), why not just use a simple integer pointer? For example:

    - (id)init {   if( (self = [super init]) ) {     // assume this is an instance variable of type NSInteger *myArray;     myArray = (NSInteger*)calloc(arraySize, sizeof(NSInteger));      // Do any other initialization that you need   }   return self; }  - (void)myMethod {   // Do whatever you need   while( objects ) { myArray[whatever]++; } }  - (void)dealloc {   free(myArray);   [super dealloc]; } 

    If your requirements call for a simple, fixed-capacity array all consisting of the same, primitive type, I think that the simple solutions are best. If the length of the array will never change (i.e., you know the length at compile time), you can use an NSInteger array as your instance variable instead of a pointer, that way you don’t have to deal with allocating the memory or freeing it. Also, in that case, you will get a zero-ed out array automatically.

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

Sidebar

Related Questions

I need to keep track of indexes/rows that are selected. When a row is
I have a web application where I need to keep track of most popular
I want to modify the glBindTexture() function to keep track of the previously binded
I need to keep the files & folders on two Windows-based, non-domain machines synchronized
I need to keep as much as I can of large file in the
I need to keep the arrow keys from being able to scroll through my
I need to keep an NSPathControl updated with the currently selected path in an
I need to keep a couple of Jena Models (OntModels, specifically) synchronized across a
The problem that I am having has to do with the need to keep
Or they (team members) need someone to keep pushing? Edit: The above line was

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.