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

  • Home
  • SEARCH
  • 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 747285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:11:15+00:00 2026-05-14T14:11:15+00:00

I have a simple iPhone app that Im learning and I want to have

  • 0

I have a simple iPhone app that Im learning and I want to have an instance variable called urlLists which is an NSDictionary

I have declared it like so:

@interface MyViewController : UIViewController <UIPickerViewDataSource, UIPickerViewDelegate>{
    IBOutlet UIPickerView *pickerView;
    NSMutableArray *categories;
    NSDictionary *urlLists;
}
@property(retain) NSDictionary *urlLists;
@end

and in the implementation:

@implementation MyViewController
@synthesize urlLists;

...

- (void)viewDidLoad {
    [super viewDidLoad];

    categories = [[NSMutableArray alloc] init];

    [categories addObject:@"Sport"];
    [categories addObject:@"Entertainment"];
    [categories addObject:@"Technology"];
    [categories addObject:@"Political"];

    NSArray *objects = [NSArray arrayWithObjects:@"value1", @"value2", @"value3", @"value4", nil];
    urlLists = [NSDictionary dictionaryWithObjects:objects forKeys:categories]; 

    for (id key in urlLists) {
        NSLog(@"key: %@, value: %@", key, [urlLists objectForKey:key]);
    }
}

...
@end

And, this all works up to here.

I have added a UIPicker to my app, and when I select one of the items, I want to Log the one picked and its related entry in my dictionary.

-(void) pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger) component {
    for (id key in self.urlLists) {
        NSLog(@"key: %@, value: %@", key, [urlLists objectForKey:key]);
    }
}

but I get the old EXC_BAD_ACCESS error…

I know Im missing something small, but what?

Thanks

EDIT::

Just fixed it, I added a retain after the dictionaryWithObjects

But I dont know why I need to, shouldnt dictionaryWithObjects create an autorelease object?

  • 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-14T14:11:15+00:00Added an answer on May 14, 2026 at 2:11 pm

    The NSDictionary was deallocated.

    You should use self.urlLists = ..., so it goes via the setter, which retains it.

    Omitting self will set the ivar directly.

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

Sidebar

Related Questions

I have a very simple iPhone app that requires a random integer from 1-100.
I have an iPhone app that shows a simple view (View 1) that has
I'm working on a very simple iPhone app, that in the end will have
I currently have a simple iPhone app that loads a custom subclass of UIView.
I have a simple iPhone app which accesses some remote data on start-up then
I have a fairly simple iPhone application that I want to have run on
I am learning iOS and I have written a simple iPhone app using iOS
I have a simple webapp in Django for an iPhone app. I want to
I'm working on an iPhone app and would like to have a simple text
I have a simple iPhone app that allows the user to upload images to

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.