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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:04:08+00:00 2026-05-23T14:04:08+00:00

In which case we need a pointer of a BOOL variable in Objective C

  • 0

In which case we need a pointer of a BOOL variable in Objective C language?

I have a code for collapsible UITableView in which there is a function declaration:

- (void)toggle:(BOOL*)isExpanded section:(NSInteger)section; 

and its definition is:

- (void)toggle:(BOOL*)isExpanded section:(NSInteger)section 
{
    *isExpanded = !*isExpanded; 
    NSArray *paths = [self indexPathsInSection:section];

    if (!*isExpanded)
    {
        [self.tableview deleteRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationFade];
    }
    else 
    {
        [self.tableview insertRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationFade];
    }

*isExpanded = !*isExpanded; What is the meaning of this statement as I have never used this kind of statement in case of BOOL Variable.

Following are other two functions of same code which are called in the sequence of above function:

- (NSArray*)indexPathsInSection:(NSInteger)section 
{
    NSMutableArray *paths = [NSMutableArray array];
NSInteger row;
    for ( row = 0; row < [self numberOfRowsInSection:section]; row++ ) 
    {
        [paths addObject:[NSIndexPath indexPathForRow:row inSection:section]];
    }
    return [NSArray arrayWithArray:paths];
}

- (NSInteger)numberOfRowsInSection:(NSInteger)section 
{
    return [[sectionDataArray objectAtIndex:section] count];
}

sectionDataArray is the array for number of rows in each section. I may be unclear but if you got my point please explain all this.

Here is the link to that code

Thanks

  • 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-23T14:04:08+00:00Added an answer on May 23, 2026 at 2:04 pm

    Pointers to variables (or pointer to pointers of objects) are useful, if you want to change their value in another function. If you pass a plain BOOL to a method, you can use it, but if you change it, this change is only local as it was passed by value. If you pass the pointer/address of the variable instead, you can also change its real value.

    This comes in handy if you need more than one return value and don’t want to wrap it up in an object. It’s also a common pattern in Cocoa where NSError variables are passed as pointers, i.e -(BOOL) doSomethingError:(NSError **)error.

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

Sidebar

Related Questions

The code below works unless p.School.SchoolName turns out to be null, in which case
I use camel case which has the first letter of all variable names, functions,
I have a pretty simple case which I started solving using foreach(), but then
I have a Boost unit test case which causes the object under test to
I have a Lucene index which is currently case sensitive. I want to add
I have a 200+ case statement in Classic ASP which is getting out of
I have some concurrent code which has an intermittent failure and I've reduced the
I need to write a function which could create any type object. It receives
In which case should you use primitive types( int ) or reference types (
I'm writing an utility ( http://reg2run.sf.net ) which in case execution without arguments works

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.