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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:25:15+00:00 2026-05-23T18:25:15+00:00

I am saving a NSMutableArray using NSUserDefaults. Then in another view controller, I would

  • 0

I am saving a NSMutableArray using NSUserDefaults. Then in another view controller, I would retrieve the NSMutableArray from the NSUserDefaults. So what I want to do is retrieve the NSString from the first NSDictionary in that array, then add it as a button to my UIActionSheet. Then I would loop it, so retrieve the second NSString from the second NSDictionary from that NSMutableArray. I would also like to keep them in the right order. So the NSString from the NSDictionary that is objectAtIndex:0 in the NSMutableArray, is the first button in the UIActionSheet?
Is this possible, and if so how would I accomplish this?

Thanks so much!

Edit (There is a leak in this code). Xcode says its in the bolded line but I am not sure, am I leaking anything here or doing anything wrong?

NSUserDefaults *prefs =[NSUserDefaults standardUserDefaults];
**NSMutableArray *accountsArray = [[prefs objectForKey:@"AccountArray"] mutableCopy];**
if ([accountsArray count] >= 2) {

    UIActionSheet *playingSheet = [[UIActionSheet alloc] initWithTitle:@"Hi?" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
    [playingSheet showInView:self.view];
    for(NSDictionary * dict in accountsArray)
    {
        NSString *name = [dict objectForKey:@"Name"];
        [playingSheet addButtonWithTitle:name];
    }
    [playingSheet release];
}

Edit2:
I get a warning when I run analyze in my app when I run the following code. Anyway the error is, Potential leak of an object in the bolded line and stored into accountsArray. That line is the second line in the edit2 post.

NSUserDefaults *prefs =[NSUserDefaults standardUserDefaults];
**NSMutableArray *accountsArray = [[prefs objectForKey:@"AccountArray"] mutableCopy];**
if ([accountsArray count] >= 2) {

UIActionSheet *playingSheet = [[UIActionSheet alloc] initWithTitle:@"Hi?" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
[playingSheet showInView:self.view];
for(NSDictionary * dict in accountsArray)
{
    NSString *name = [dict objectForKey:@"Name"];
    [playingSheet addButtonWithTitle:name];
}
[playingSheet 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-23T18:25:16+00:00Added an answer on May 23, 2026 at 6:25 pm

    Something like this?

    UIActionSheet * sheet = [[UIActionSheet alloc] initWithTitle .......]
    
    
    for(NSDictionary * dict in myMutableArray)
    {
        NSString * str = [dict objectForKey:@"MyStringKey"];
        [sheet addButtonWithTitle:str];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting data from NSTextField, and saving data in NSMutableArray. I want to
I'm saving some data using a series of NSDictionaries, stored in an NSMutableArray and
I have a table view that i want to populate with information from xml.
Saving a Word 2003 document to XML and then back results in a reduced
After saving a String value into memcached using the Danga client, I attempted to
I am saving all the words from a file like so: sentence = fileName
I am saving an NSMutableArray in a Transformable property in my Core Data store.
I have noticed that the saving of NSUserDefaults takes a while. How can I
In this code from an array i am selecting a dictionary,modifying it and saving
I have a function which returns an NSMutableArray which is fetched from CoreData .

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.