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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:34:21+00:00 2026-05-25T01:34:21+00:00

I have been searching everywhere on the web and trying everything that I can

  • 0

I have been searching everywhere on the web and trying everything that I can think of so far to no avail. Here is my problem:
In my program I have a class called Scale, Scale has several properties. The user can add scales to a tableView by clicking a button called addScale. When addScale is pressed, I add it to a OrderedMutableSet. I use the set to store the scales and prevent duplicate scales. I had to override the isEqual method and the Hash method to fool the computer into thinking that two Scales with the same properties are exactly the same. This works fine. But when I open the app and have had previously some scales in the tableView, I have archiving implemented so these scales reappear, as expected. This time, when addScale is pressed, I get an exception:

    -[__NSOrderedSetI addObject:]: unrecognized selector sent to instance 0x746dbf0
    2011-08-29 13:20:49.095 MusicLog[678:f203]
    *** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
    reason: '-[__NSOrderedSetI addObject:]: unrecognized selector sent to instance 0x746dbf0'

Here is the code for my isEqual method and my Hash method:
(tonic, mode, rhythm, octaves, and tempo are all ints)

- (NSUInteger)hash
{
    NSUInteger prime = 31;
    NSUInteger result = 1;
    result = prime * result + tonic;
    result = prime * result + mode;
    result = prime * result + rhythm;
    result = prime * result + octaves;
    result = prime * result + tempo;
    NSLog(@"%u", result);
    NSLog(@"%u", NSUIntegerMax);

    return result;
}


- (BOOL)isEqual:(Scale *)object
{
    if ((tonic == [object tonic])
        && (mode == [object mode])
        && (rhythm == [object rhythm])
        && (octaves == [object octaves])
        && (tempo == [object tempo]))
        return YES;
    else 
        return NO;
}

Here is the code for my addScale method:

- (IBAction)addScale:(id)sender
{
    Scale *chosenScale = [[Scale alloc] init];
    [chosenScale setTonic:[myPicker selectedRowInComponent:0]];
    [chosenScale setMode:[myPicker selectedRowInComponent:1]];
    [chosenScale setRhythm:[myPicker selectedRowInComponent:2]];
    [chosenScale setOctaves:[octavesSegmentedControl selectedSegmentIndex] + 1];
    [chosenScale setTempo: (int) [tempoStepper value]];
    [[ScaleStore defaultStore] addScale:chosenScale];
}

the addScale method of the ScaleStore just calls addObject from a NSOrderedMutableSet which is where all the scales are stored.

Any help you can give is greatly appreciated.

Thank you,

K

  • 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-25T01:34:22+00:00Added an answer on May 25, 2026 at 1:34 am

    When you unarchive, the objects are restored to an immutable version (NSMutableSet becomes NSSet, NSMutableArray becomes an NSArray, etc.)

    Just create a new NSOrderedMutableSet with objects from the restored set.

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

Sidebar

Related Questions

I have been searching EVERYWHERE for this IObjectWithChangeTracker Interface that I think I need
I have been searching everywhere but can't seem to find a solution to this
So I have been searching everywhere for a solution to this problem. I have
I have been searching everywhere for a proper solution to my problem and I
I have been searching everywhere for an explanation. Here's a real example taken from
Been searching everywhere and can't find a way to do this. I have a
I have been searching everywhere and nothing so far has worked for me. Basically
I have been searching everywhere but I could not find an answer. I need
I have been searching around using Google but I can't find an answer to
I have been searching for the past through days, trying to figure out how

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.