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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:06:35+00:00 2026-06-10T21:06:35+00:00

I am trying to enumerate over a bunch of objects which, depending on the

  • 0

I am trying to enumerate over a bunch of objects which, depending on the situation, may be either an NSArray or an NSOrderedSet. Since both conform to NSFastEnumeration, I would expect this to work:

id<NSFastEnumeration> enumerableSet =
(test) ?
[NSArray arrayWithObjects:@"one", @"two", @"three", nil] :
[NSOrderedSet orderedSetWithObjects:@"one", @"two", @"three", nil];

NSEnumerator *e = [enumerableSet objectEnumerator];

However, I get the following compiler error:

No known instance method for selector ‘objectEnumerator’.

I suspect there is some syntax error here, I haven’t worked much with the id construct before. I could convert one or both of the sets to a common class, but if possible I’d like to understand better what’s going on here.

  • 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-10T21:06:37+00:00Added an answer on June 10, 2026 at 9:06 pm

    objectEnumerator is not declared in the NSFastEnumeration protocol, therefore using [enumerableSet objectEnumerator]; will not work because you are working with type `id’ which doesn’t define that method.

    Since objectEnumerator is declared as a property of a NSArray and a NSSet (with no common super class), you will need to set the enumerator from a variable which knows that it is an array/set. I.e.:

    NSEnumerator *e = 
    (test) ?
    [[NSArray arrayWithObjects:@"one", @"two", @"three", nil] objectEnumerator]:
    [[NSOrderedSet orderedSetWithObjects:@"one", @"two", @"three", nil] objectEnumerator];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataTable that I'm trying to enumerate over with the AsEnumerable extension
I am trying to enumerate and build the following fiddle with Mustache.js: $(function ()
I'm trying to enumerate all hosts in an XML document, create a db entry
I'm trying to enumerate through all the Controls of a Page, but all I
I'm trying to enumerate all the permissions used by all the installed packages, however
I'm trying to enumerate, in c#, the reports for a user on reporting services.
I am trying to enumerate all the namespaces in a document using XPath. The
Ok, Im having major problems trying to expose this enumerated type over my webservice.
I was trying my hand over System.Gloablization in a small desktop app. I am
I'm trying to iterate over an Enumerable collection of mix of nullable types However

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.