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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:59:59+00:00 2026-06-13T13:59:59+00:00

I have these declarations in header file: Note: I won’t explain the whole code,

  • 0

I have these declarations in header file:
Note: I won’t explain the whole code, I think it is easy to understand

typedef void (^loopCell)(id cell);
-(id)allCells:(loopCell)cell;

And allCells function implementation:

-(id)allCells:(loopCell)cell
{
    for (AAFormSection *section in listSections)
    {
        for (id _cell in section.fields) {
            cell(_cell);
        }
    }
    return nil;
}

The usage of allCells function:

-(void)setFieldValue:(NSString *)value withID:(int)rowID
{    
    [self allCells:^(id cell) {
        if([cell isKindOfClass:[AAFormField class]]) {
            AAFormField *_cell = (AAFormField *)cell;
            if(_cell.rowID == rowID) {
                _cell.value = value;
                //return; Here I want to terminate loop
            }
        }
    }];
}

My problem is, I can’t terminate allCells loop in the middle (actually when I found object I need in the loop, I don’t want iterate through other objects)

How can I stop allCells loop in the middle?

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

    Look at the docs for NSArray enumerateObjectsUsingBlock:. They setup the block signature to take a BOOL pointer. Set the stop BOOL to YES to cause the iteration to stop.

    typedef void (^loopCell)(id cell, BOOL *stop);
    
    -(id)allCells:(loopCell)cell {
        BOOL stop = NO;
        for (AAFormSection *section in listSections) {
            for (id _cell in section.fields) {
                cell(_cell, &stop);
                if (stop) {
                    break;
                }
            }
            if (stop) {
                break;
            }
        }
    
        return nil;
    }
    
    -(void)setFieldValue:(NSString *)value withID:(int)rowID {    
        [self allCells:^(id cell, BOOL *stop) {
            if([cell isKindOfClass:[AAFormField class]]) {
                AAFormField *_cell = (AAFormField *)cell;
                if(_cell.rowID == rowID) {
                    _cell.value = value;
                    if (stop) {
                        *stop = YES;
                    }
                }
            }
        }];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a header file with about 400 function declarations and its corresponding source
I have a header file that has a number of declarations like this: extern
These are my declarations. Why it doesn't identify signed as a type? I have
I have these 3 tables: and I'm using this code to join them together
So I have a header file and 2 .c files within the beginnings of
I have the following code, and for the life of me, I cannot understand
I currently have a program where my main code is in a file main.cpp.
Possible Duplicate: C++ - Forward declaration so in my header file i have a
I have some constants defined in a header file that contain the max length
In my game I have a header file that contains properties and functions for

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.