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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:19:50+00:00 2026-05-30T10:19:50+00:00

How could I enumerate an NSArray containing objects of multiple types, to get all

  • 0

How could I enumerate an NSArray containing objects of multiple types, to get all the indexes where an NSString is found, then be able to refer to each index in order by saying something like…

NSString *firstOccurrence = [myArray objectAtIndex:firstOccurrence];
NSString *secondOccurrence = [myArray objectAtIndex:secondOccurrence];
NSString *thirdOccurrence = [myArray objectAtIndex:thirdOccurrence];

Thanks!

EDIT: How I’m using the code (Updated with @NJones example.)

I need the Integer value of the index where the strings are stored in the array, to update the NSUInteger property “wordDisplayed” with that value.

In my code here, I’m using a modified version of UIActionSheet to accept blocks:
https://github.com/zoul/Lambda-Alert

NSIndexSet *stringLocations = [arrayInLesson indexesOfObjectsPassingTest:^(id obj, NSUInteger idx, BOOL *stop){
    return [(NSObject *)obj isKindOfClass:[NSString class]];
}];

NSArray *passingObjects = [arrayInLesson objectsAtIndexes:stringLocations];

sectionHeadersAct = [[LambdaSheet alloc] initWithTitle:@"Book 2 Lesson 1"];
[sectionHeadersAct addButtonWithTitle:@"D. E. F. & G. Teach New Letters" block:^{ 
    //Do nothing yet
}];
[sectionHeadersAct addButtonWithTitle:[passingObjects objectAtIndex:0] block:^{
    NSLog(@"First");
    wordDisplayed = theIndexOfThisStringIn_arrayInLesson;
}];
[sectionHeadersAct addButtonWithTitle:[passingObjects objectAtIndex:1] block:^{ 
    NSLog(@"Second"); 
    wordDisplayed = theIndexOfThisStringIn_arrayInLesson;
}];
[sectionHeadersAct addButtonWithTitle:[passingObjects objectAtIndex:2] block:^{ 
    NSLog(@"Third"); 
    wordDisplayed = theIndexOfThisStringIn_arrayInLesson;
}];
[sectionHeadersAct addButtonWithTitle:[passingObjects objectAtIndex:3] block:^{ 
    NSLog(@"Fourth"); 
    wordDisplayed = theIndexOfThisStringIn_arrayInLesson;
}];
[sectionHeadersAct setDismissAction:^{
    //Do nothing yet
}];
[sectionHeadersAct showInView:self.view];
  • 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-30T10:19:52+00:00Added an answer on May 30, 2026 at 10:19 am

    You can get an NSIndexSet of the location of objects that you define with indexesOfObjectsPassingTest:. Like so:

    -(void)findStrings{
        NSArray *randomObjects = [NSArray arrayWithObjects:[NSNull null], @"String", [NSNull null], @"String", [NSNull null], nil];
        NSIndexSet *stringLocations = [randomObjects indexesOfObjectsPassingTest:^(id obj, NSUInteger idx, BOOL *stop){
            return [(NSObject *)obj isKindOfClass:[NSString class]];
        }];
        NSLog(@"strings %@",stringLocations);
    
            // You can get an array of just the passing objects like so:
        NSArray *passingObjects = [randomObjects objectsAtIndexes:stringLocations];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had thought I could enumerate the types using IMetaDataImport.EnumTypeDefs and for each of
Someone could tell me where I can find the list (or all) patch already
I want to enumerate all the loaded segments of a module given a module
I'm interested in finding a way to enumerate all accessible devices on the local
I'm writing a service application that needs to enumerate all current user sessions, and
On page load is there a way to enumerate all the nest user controls
Is there any way to enumerate all of a character's Unicode properties in Ruby?
I would like to enumerate all DCs in a domain (where current user nor
Consider the following graph: I'm trying to find a way to enumerate all possible
In former versions of Parallel Extensions you could set the number of threads: enumerable.AsParallel(numberOfThreads)

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.