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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:03:01+00:00 2026-06-09T05:03:01+00:00

I have a sorted array containing the names of all the speakers from a

  • 0

I have a sorted array containing the names of all the speakers from a long series of presentations. I’ve pasted the code below, but my specific problem comes entirely inside the second ‘for’ loop. There are multiple presenters who have more than one entry in MyClass.speeches. So the first time I hit the ‘if’ statement inside the second ‘for’ loop, and it evaluates to true, I see the log statement “added a speech…”. However, the second time it should evaluate to true (as verified by the log statement directly above the ‘if’), I never see the “added a speech…” line printed to the log. So why am I not entering the ‘if’ after the first time that ‘item.speaker’ and ‘obj’ are the same?

[speakers sortUsingSelector:@selector(compare:)];
   for (id obj in speakers) { 

     //now create a unique list of speakers
        if ([uniqP containsObject:obj]) {
            NSLog(@"already have this object");
        }
        else {
            [uniqP addObject:obj];

            //now that we've found a new speaker, we need to go through the entire list of speeches and populate
            //them in the correct order.
            self.speechesByPresenter = [[NSMutableArray alloc] init];
            for (int j=0; j<numEntries; j++) {
                SpeechesItem *item = [MyClass.speeches objectAtIndex:j];
                NSLog(@"  %@--%@--%d  (%@)", item.speaker, obj, j, item.title);
                if(item.speaker == obj) {
                    [self.speechesByPresenter addObject:item];
                    NSLog(@"added a speech, %@ now has %d", item.speaker, [self.speechesByPresenter count]);
                }
            }
        }
    }
  • 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-09T05:03:03+00:00Added an answer on June 9, 2026 at 5:03 am

    Instead of item.speaker == obj which compares pointers, you should use [item.speaker isEqualToString:obj] which compares contents of strings.

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

Sidebar

Related Questions

I have an array of values which is almost, but not quite sorted, with
I have an sorted array which contains first names of people. This array has
I have a sorted array of doubles (latitudes actually) that relatively uniformally spread out
I have a sorted mutable array of a class called Topic. The topics represent
1-)For sorted array I have used Binary Search. We know that the worst case
I have a array with users sorted by score. I only want to output
Suppose I have a sorted array of integers int[] , and I want to
We have two sorted arrays of the same size n. Let's call the array
Possible Duplicate: Java - Distinct List of Objects i have a sorted array of
I have a sorted integer array on the device, e.g.: [0,0,0,1,1,2,2] And I want

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.