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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:02:41+00:00 2026-05-29T09:02:41+00:00

I have an NSTableview which s bound to a NSArrayController. The Table/Arraycontroller contains Core

  • 0

I have an NSTableview which s bound to a NSArrayController. The Table/Arraycontroller contains Core Data “Person” entities. The people are added to the NSTableview by the GUI’s user.

Let’s say a person entity looks like

NSString* Name;
int Age;
NSString* HairColor;

Now I want to iterate over what is stored in the array controller to perform some operation in it. The actual operation I want to do isn’t important I don’t really want to get bogged down in what I am trying to do with the information. It’s just iterating over everything held in the NSArraycontroller which is confusing me. I come from a C++ and C# background and am new to Cocoa. Let’s say I want to build a NSMutableArray that contains each person from nsarraycontroller 1 year in the future.

So I would want to do something like

NSMutableArray* mutArray = [[NSMutableArray alloc] init];

foreach(PersonEntity p in myNsArrayController)  // foreach doesn't exist in obj-c
{

  Person* new_person = [[Person alloc] init];
  [new_person setName:p.name];
  [new_person setHairColor:p.HairColor];
  [new_person setAge:(p.age + 1)];
  [mutArray addObject:new_person];

}

I believe the only thing holding me back from doing something like the code above is that foreach does not exist in Obj-c. I just don’t see how to iterate over the nsarraycontroller.

Note: This is for OSX so I have garbage collection turned on

  • 1 1 Answer
  • 1 View
  • 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-29T09:02:42+00:00Added an answer on May 29, 2026 at 9:02 am

    You’re looking for fast enumeration.

    For your example, something like

    for (PersonEntity *p in myNsArrayController.arrangedObjects)
    {
        // Rest of your code
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an NSTableView bound to a core-data-backed NSArrayController by binding individual columns to
I have a custom NSTableView subclass which is bound to a data source (an
I have an NSTableView which is bound to an NSArrayController. I would like to
I have an NSTableView bound to an NSArrayController , which is bound to an
I have an NSTableView which gets its data from an NSArrayController and I need
I have an NSTableView that contains a few columns that are populated with data.
I have an NSTableView which is bound to an NSDictionaryController. I have set this
I have an array controller which is bound to an nstableview. I also have
In my project, I have two Core Data entities. One is the grouping (can
I have an NSTableView that I add objects to (through core data). I came

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.