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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:29:51+00:00 2026-06-11T07:29:51+00:00

I read many posts regarding the same error message on SO, but none of

  • 0

I read many posts regarding the same error message on SO, but none of those solutions works in my situation. So please read the code before recommend other posts. Thanks in advance.

I set exception break point, and found the problem resides in [self.countryNameDictionary setObject:array forKey:initial];

In AppDelegate.h

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (nonatomic,copy) NSMutableDictionary *countryNameDictionary;
@property (nonatomic,copy) NSMutableArray *countryNameInitials;
@end

In AppDelegate.m

#import "AppDelegate.h"

@implementation AppDelegate     
@synthesize window = _window;
@synthesize countryNameDictionary = _countryNameDictionary;
@synthesize countryNameInitials = _countryNameInitials;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    NSMutableArray *permanentArray = [[NSMutableArray alloc]init];
    self.countryNameDictionary = [[NSMutableDictionary alloc]init];
    self.countryNameInitials = [[NSMutableArray alloc]init ];

    [[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:@"isFirstLaunch"];

    // run this code only once by creating and checking a user defaults key
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"isFirstLaunch"] isEqualToString:@"YES"])
    {
        // locate and convert txt file to string
        NSString *path = [[NSBundle mainBundle] pathForResource:@"country_name" ofType:@"txt"];
        NSString *string = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];

        // seperate string into array
        permanentArray = [[string componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]mutableCopy];
        // strip white space string
        permanentArray = [[permanentArray filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF != ''"]]mutableCopy];

        // enumerate a-z to set the two global variables
        for (int asciicode =65; asciicode<=90; asciicode++)
        {
            NSString *initial = [NSString stringWithFormat:@"%c",asciicode];
            self.countryNameInitials = [NSMutableArray arrayWithObject:initial];

            NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF BEGINSWITH[cd] %@",initial];
            NSMutableArray *array = [[permanentArray filteredArrayUsingPredicate:predicate]mutableCopy];

            // populate the dictionary with initial-country-names pair
            [self.countryNameDictionary setObject:array forKey:initial]; // PROBLEM IS HERE

            NSLog(@"self.countrynameDictionary is %@",self.countryNameInitials);
        }

        // set to a non-nil value
        [[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"isFirstLaunch"];
    }

    return YES;
}
  • 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-11T07:29:52+00:00Added an answer on June 11, 2026 at 7:29 am

    Your property definition returns copy of original object when using getter on said property. Since it’s a copy, you get immutable object. Try changing copy to strong or retain depending on your used memory management.

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

Sidebar

Related Questions

I have read many posts regarding detection of popup blocker by javascript code but
OK I have read many posts regarding Dual Licensing using MIT and GPL licenses.
I have read in many posts that global variables are bad, but I need
i have read many posts but can not find my answer.my question is a
I have read many posts(problems) with IE and jquery posts, but never thought I'd
I am learning dependency properties. I read many posts & books but still I
I've read many of the posts regarding this issue and I can't find one
Having read many of Matthew Weier O'Phinney's posts regarding implementing ACL into Models, I
I have read many posts about this now but I do not still understand
I have read many posts on Session-scoped data in MVC, but I am still

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.