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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:59:39+00:00 2026-06-09T14:59:39+00:00

I am a relatively new iPhone/objective-c programmer and I have an issue that makes

  • 0

I am a relatively new iPhone/objective-c programmer and I have an issue that makes me feel quite out of my element.

I am trying to use a class method that creates a dictionary which I try to access in other methods. But the dictionary is…for lack of a better term — trippin’.

Here is my code in DynamoDBManager.m (the parts that I think are important):

    static NSMutableDictionary *voiceMap = nil;

    @implementation DynamoDBManager

    +(NSMutableDictionary *)createVoiceMap{
    NSLog(@"creating voice map...");
    if (voiceMap == nil){
        NSLog(@"Voice Map was nil");
        voiceMap = [NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:
        @"piano", @"trumpet", @"hi_hat1", @"p", @"t", @"h", 
        @"acquitar", @"bass_drum1", @"clarinet", @"hi_tom", @"mid_tom", @"low_tom", @"crash_cymbal1", @"ride_cymbal1", @"snare_drum1", @"snare_drum2", @"violin", 
        @"g", @"b", @"c", @"i", @"m", @"l", @"y", @"r", @"s", @"a", @"v", nil] 
        forKeys:[NSArray arrayWithObjects:
        @"p", @"t", @"h", @"piano", @"trumpet", @"hi_hat1", 
        @"g", @"b", @"c", @"i", @"m", @"l", @"y", @"r", @"s", @"a", @"v", 
        @"acquitar", @"bass_drum1", @"clarinet", @"hi_tom", @"low_tom", @"mid_tom", @"crash_cymbal1", @"ride_cymbal1", @"snare_drum1", @"snare_drum2", @"violin", nil]];
    }
    NSLog(@"done creating voice map");
    return voiceMap;}

    +(NSString *)generateNoteCipherGivenX:(int)x Y:(int)y andNote:(id)theNote{
    NSLog(@"%@ -- voiceMap", voiceMap);
    NSString *voiceCipherString = [[DynamoDBManager createVoiceMap] objectForKey:[theNote getVoice]];
    if ([theNote isKindOfClass:[PitchedNote class]]) {
        int duration2 = [theNote getDuration];
        NSString *cipher = [NSString stringWithFormat:@"%@%i%i%i,", voiceCipherString, y+10, duration2, x];
        return cipher;
    }
    else{
        NSString *cipher = [NSString stringWithFormat:@"%@%i%i%i,", voiceCipherString, y, 0, x];
        return cipher;
    }
}

In another method in DynamoDBManager, I call

 [DynamoDBManager generateNoteCipherGivenX:curX Y:curY andNote:curNote];

It has logged some strange errors, including, on three different runs of the app:

2012-08-10 21:53:48.090 createAccount[537:207] __NSCFDictionary -- type
2012-08-10 21:53:48.091 createAccount[537:207] {
IOProviderClass = IOFireWireUnit;
"Unit_SW_Version" = 16;
"Unit_Spec_ID" = 2599;
} -- voiceMap

2012-08-10 21:57:55.635 createAccount[580:207] __NSMallocBlock__ -- type
2012-08-10 21:57:55.636 createAccount[580:207] <__NSMallocBlock__: 0x810cb50> -- voiceMap

2012-08-10 22:38:10.044 createAccount[1188:207] -[__NSMallocBlock__ objectForKey:]: unrecognized selector sent to instance 0x77700e0
2012-08-10 22:38:10.044 createAccount[1188:207] Exception: -[__NSMallocBlock__ objectForKey:]: unrecognized selector sent to instance 0x77700e0

I must be doing something incredibly wrong to get such erratic behavior. What is it?

  • 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-09T14:59:41+00:00Added an answer on June 9, 2026 at 2:59 pm

    I bet you are not using ARC (Automatic Reference Counting) so you should retain you dictionary:

        voiceMap = [[NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:
        @"piano", @"trumpet", @"hi_hat1", @"p", @"t", @"h", 
        @"acquitar", @"bass_drum1", @"clarinet", @"hi_tom", @"mid_tom", @"low_tom", @"crash_cymbal1", @"ride_cymbal1", @"snare_drum1", @"snare_drum2", @"violin", 
        @"g", @"b", @"c", @"i", @"m", @"l", @"y", @"r", @"s", @"a", @"v", nil] 
        forKeys:[NSArray arrayWithObjects:
        @"p", @"t", @"h", @"piano", @"trumpet", @"hi_hat1", 
        @"g", @"b", @"c", @"i", @"m", @"l", @"y", @"r", @"s", @"a", @"v", 
        @"acquitar", @"bass_drum1", @"clarinet", @"hi_tom", @"low_tom", @"mid_tom", @"crash_cymbal1", @"ride_cymbal1", @"snare_drum1", @"snare_drum2", @"violin", nil]] retain];
    

    Since you don’t retain the dictionary, it is deallocated soon after and the memory voiceMap is pointing to is very likely reused for other objects.

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

Sidebar

Related Questions

I am relatively new to Objective-C / iPhone programming, and have only created single
I'm relatively new to objective-c...I'm using the iphone 3.0 SDK I have a UIView,
I'm relatively new to iPhone programming but have read my way through a hefty
I am relatively new to IPhone coding, although I have reached the point of
Im relatively new to iPhone development and Im trying to implement Facebook functions in
I'm still relatively new to XCode. I'm trying to build an iPhone application and
I am relatively new to Objective-C and now I have a problem in my
I'm relatively new to iphone programming, and I've been starting out with cocos2d. I
I have done some iPhone application development but still am relatively new at it.
I am relatively new to iPhone programming, and I have a considerably complex app

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.