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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:08:26+00:00 2026-05-20T12:08:26+00:00

I am relatively new to Objective-C and now I have a problem in my

  • 0

I am relatively new to Objective-C and now I have a problem in my iPhone app that I don’t fully understand.
I try to use a NSMutableDictionary, this does not seem to work as i expect for some reason. When I run the debugger and do po numberToCallerMap to see the dictionary, I get an exception. I have read the documentation for NSMutableDictionary on how to initialize it, but I can not see what I am doing wrong. Help and advice are appreciated. The variable causing me problem is numberToCallerMap, here is the relevant function:

- (void)setData:(NSString*)value{
[list release];
list = [[NSMutableArray alloc] init];
SBJSON *json = [[[SBJSON alloc] init] autorelease];
NSMutableDictionary* numberToCallerMap;
CallerInfo* caller;
NSDictionary* callerInfo;

@try {      
    NSArray *array = (NSArray*)[json objectWithString:value];       
    // reading all the items in the array one by one  
    numberToCallerMap = [NSMutableDictionary dictionary];

    for (id *item in array) {  

        // if the item is NSDictionary (in this case ... different json file will probably have a different class)  
        NSDictionary *dict2 = (NSDictionary *) item;  
        CallInfo *data = [CallInfo alloc];           
        [data initFromDictionary:dict2];


        callerInfo = (NSDictionary*)[dict2 valueForKey:@"caller"] ;

             //Here, we want the phonenumber to be part of the CallerInfo object instead.
             // It is sent from the server as part of the Call-object
        NSString* number = (NSString*)[dict2 valueForKey:@"phoneNumber"];
        [callerInfo setValue:number forKey:@"phoneNumber"];

        caller = (CallerInfo*)[numberToCallerMap valueForKey:number];
        if(caller == nil || [caller isKindOfClass:[NSNull class]]){
            caller = [CallerInfo alloc];
            [caller initFromDictionary:callerInfo];

            [numberToCallerMap setValue:caller forKey:number];  
            [list insertObject:caller atIndex:0];
            }
        [caller addRecentCall:data];            
     } 
}
@catch (NSException * e) {
    [list release];
    list = [[NSMutableArray alloc] init];
}
@finally {
    [numberToCallerMap release];
}
}
  • 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-20T12:08:27+00:00Added an answer on May 20, 2026 at 12:08 pm

    This is probably not the only problem, but you are not alloc-ing your numberToCallerMap dictionary, you are getting it from a convenience class method — [NSMutableDictionary dictionary] — that returns it autoreleased. So you should not call release on it yourself.

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

Sidebar

Related Questions

I'm relatively new to objective-c...I'm using the iphone 3.0 SDK I have a UIView,
I'm relatively new to the world of Objective-C and have a class that I've
I am relatively new to Objective C/iPhone Development. I am developing a simple app
I'm relatively new to Objective-C and really don't know much about it yet, so
I am relatively new to Objective C and need some array help. I have
I am relatively new to Objective C/iOS development so I realize that this may
I'm relatively new to Objective-C and I have an enum with a corresponding array
relatively new to iphone dev, but i was interested in the app Path. its
I'm relatively new to objective-C and I'm having a problem with a 2D NSMutableArray
i m relatively new in Objective C, i have designed a server-client application and

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.