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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:51:36+00:00 2026-05-24T22:51:36+00:00

I am semi-new to cocoa programming, however I have worked quite a bit in

  • 0

I am semi-new to cocoa programming, however I have worked quite a bit in C++;

I am having some issues with the NSSavePanel class. Whenever I use it (as shown below), I can see (by using breakpoints) that the code tries to execute the ending bracket. I then get a BAD_ACCESS message from Xcode in the main.h file. I cannot for the life of me figure out what I am doing wrong. Here is the code:

- (void)scannerDevice:(ICScannerDevice*)scanner didCompleteScanWithError:(NSError*)error;
{
    NSLog( @"scannerDevice: \n%@\ndidCompleteScanWithError: \n%@\n", scanner, error );
    [mProgressIndicator setHidden:YES];

    NSSavePanel *savePopup = [[NSSavePanel alloc]init];
    [savePopup runModal];

    NSMutableString *saveString = [[NSString alloc] init];
    saveString = [[savePopup URL] absoluteString];
    [saveString deleteCharactersInRange:NSMakeRange(0, 16)];
    [saveString appendString:@".jpeg"];

    NSLog(@"[[ADDRESS: %@", saveString); //Outputs /Users/tannerdsilva/Documents/TestFolder/NewName.jpeg
    NSError *errorSave = [[NSError alloc] init];

    [manager moveItemAtPath:[@"~/Foo.jpeg" stringByExpandingTildeInPath] toPath:[[savePopup URL] absoluteString] error:&errorSave]; // ~/Foo.jpeg does exist

    NSLog(@"ERROR: %@", errorSave);
    [saveString dealloc];
    [savePopup dealloc];

}

When I hard code the new destination and remove the NSSavePanel, I don’t get any crashes.

Thank you ahead of time, and I apologize if this is a simple fix.

  • 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-24T22:51:38+00:00Added an answer on May 24, 2026 at 10:51 pm

    There are a couple of issues with your code.

    • You declare saveString as an NSMutableString but initialize it as an (immutable) NSString.
    • You’re then not using that string at all but replace it with the autoreleased (and immutable) NSString that’s returned from absoluteString, causing the original string to leak.
    • NSString responds to neither deleteCharactersInRange: nor to appendString (those are methods of NSMutableString).
    • You’re leaking errorSave which you should initialize as nil anyway.
    • You should never ever call dealloc yourself, use release instead. But don’t release saveString because it’s already autoreleased (see above), you’re over-releasing it here which will cause a crash when the autorelease pool is drained.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some simple code: ManagementObjectSearcher searcher = new ManagementObjectSearcher(select * from Win32_UninterruptiblePowerSupply); ManagementObjectCollection
I have some (semi) complex conditional formatting to do in Excel. I can get
I have just started to use NHibernate 3.2 with its new Conformist API, having
I'm writing some semi-portable code and want to be able to detect when I'm
We have a semi-weird issue for our site. Consistently, from 1 anonymous* user the
I have a semi-large web application that we run locally and I need to
I'm building a semi-elaborate RadGrid where within my NestedViewTemplate I want to have a
I'm using some semi-transparent PNGs as background-images on various websites. These are usually something
I am semi-new to android development. I am getting ready to design a project
I'm semi-new to writing ASP.Net applications using master pages and I've run into an

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.