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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:28:17+00:00 2026-05-19T22:28:17+00:00

I am not a Cocoa developer, but I have been dabbling in it to

  • 0

I am not a Cocoa developer, but I have been dabbling in it to build some plugins for PhoneGap. This particular plugin method is either 1) crashing the app without saying why or 2) complaining about how I release/don’t release an object. I have tried a ton of things on my end, including using an Enumerator instead of the for loop. If anyone can point me in the right direction, that would be awesome. I don’t mind legwork:

- (void)getPreferences:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options {
    NSUInteger argc = [arguments count];
    NSString* jsCallback = nil;

    if (argc > 0) {
        jsCallback = [arguments objectAtIndex:0];
    } else {
        NSLog(@"Preferences.getPreferences: Missing 1st parameter.");
        return;
    }

    NSDictionary *defaults = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
    NSMutableArray *keys = (NSMutableArray *) [options objectForKey:@"keys"];
    NSMutableDictionary *values = [[NSMutableDictionary alloc] init];

    NSUInteger ky = [keys count];
    for (int i = 0; i < ky; i ++) {
        @try {

            [values  setObject:[defaults objectForKey:[keys objectAtIndex:i]] forKey:[keys objectAtIndex:i]];
        }
        @catch (NSException * err) {
            NSLog(@"Error %@", err);
        }
    }

    [keys release];

    NSString* jsString = [[NSString alloc] initWithFormat:@"%@(%@);", jsCallback, [values JSONRepresentation]];

    [defaults release];
    [values release];

    [webView stringByEvaluatingJavaScriptFromString:jsString];

    [jsString release];
}

Human version:

  1. options contains a dictionary with a single key of “keys”
  2. that key contains an array of strings (that are going to be used as keys for lookup)
  3. I want to loop through that array and
  4. For every value that exists in defaults for that key, copy it to values using the same key
  5. Finally, I want to send that values back as JSON (This part was working when I just passed the entire defaults object in, so I think the JSON method is working)
  • 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-19T22:28:18+00:00Added an answer on May 19, 2026 at 10:28 pm

    From your code, it follows that you ‘own’ objects values and jsString (the ones you created with alloc), so you should release them and not any other.
    You can read more on memory management here.

    Is this the whole code? Also, what exactly error do you get?

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

Sidebar

Related Questions

Does Android have an equivalent to Cocoa's viewDidLoad and viewDidAppear functions? If not, then
Not sure if this is the right place for MDX question but it seemed
I have two applications: 1) A multithreaded cocoa gui app. 2) A unix command
I have rich-text file with a few images and text. In my Cocoa app
Not sure why this isn't working. When people click the 'edit' button of my
Not sure if this really belongs here, so please move it if it doesn't.
Not getting into too many specifics, this is a high level question. I've always
Im not getting the data correctly. this just gave me nothing!? function getUser() {
My application handles with files of type *.mndl which is not more than a
In the developer documentation, it says: If your application or thread is long-lived 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.