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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:13:38+00:00 2026-05-31T18:13:38+00:00

So I need to add the objects from an NSArray that the user has

  • 0

So I need to add the objects from an NSArray that the user has chosen using an NSOpenPanel and put all the filenames into this array. Then I have an NSMutableArray called arguments that I am putting the arguments programmatically. Then I need to add these objects from the NSArray to the end of this NSMutableArray. So I use [NSMutableArray addObjectsFromArray:NSArray] and that keeps giving me an error.

This is what I’m doing with the code:
AppDelegate.h

#import <Cocoa/Cocoa.h>

@interface ZipLockAppDelegate : NSObject <NSApplicationDelegate> {
    IBOutlet NSTextField *input;
    IBOutlet NSTextField *output;
    IBOutlet NSTextField *password;
    NSArray *filenames;
    NSMutableArray *arguments;
    NSArray *argumentsFinal;
}

@property (assign) IBOutlet NSWindow *window;
@property (retain) NSArray *filenames;
@property (copy) NSMutableArray *arguments;

- (IBAction)chooseInput:(id)sender;
- (IBAction)chooseOutput:(id)sender;
- (IBAction)createZip:(id)sender;

@end

AppDelegate.m

#import "ZipLockAppDelegate.h"

@implementation ZipLockAppDelegate

@synthesize window = _window;
@synthesize filenames;
@synthesize arguments;

- (IBAction)chooseInput:(id)sender {
    NSOpenPanel *openZip = [[NSOpenPanel alloc] init];
    [openZip setCanChooseFiles:YES];
    [openZip setCanChooseDirectories:YES];
    [openZip setCanCreateDirectories:NO];
    [openZip setAllowsMultipleSelection:YES];
    [openZip setTitle:@"Select All Files/Folders to be zipped"];
    int result = [openZip runModal];
    if (result == 1) {
        filenames = [openZip filenames];
    }
}

- (IBAction)createZip:(id)sender {
    [progress startAnimation:self];
    arguments = [NSMutableArray arrayWithObjects:@"-P", [password stringValue], [output stringValue], nil];
    [self.arguments addObjectsFromArray:filenames];
    argumentsFinal = [[NSArray alloc] initWithArray:self.arguments];
    NSTask *makeZip = [[NSTask alloc] init];
    [makeZip setLaunchPath:@"/usr/bin/zip"];
    [makeZip setArguments:argumentsFinal];
    [makeZip launch];
    [makeZip waitUntilExit];
    [progress stopAnimation:self];
}

And this is the error I keep getting in the log. I can’t figure out why I’m getting this.

EXC_BAD_ACCESS(code=13,address=0x0)

This points to the line [arguments addObjectsFromArray:filenames];

I can only make out the first part about the selector and the instance but I don’t know what it means. Help…

  • 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-31T18:13:39+00:00Added an answer on May 31, 2026 at 6:13 pm

    Be consistent. To begin with, prefix all your instance variables with an underscore, not just some of them.

     // Change this...
    @synthesize window = _window;
    @synthesize filenames;
    @synthesize arguments;
    
    //...to this
    @synthesize window = _window;
    @synthesize filenames = _filenames;
    @synthesize arguments = _arguments;
    

    Then you won’t be able to do this anymore:

    arguments = [NSMutableArray arrayWithObjects:@"-P", [password stringValue], [output stringValue], nil];
    

    Note that on the very next line, you’re doing this:

    [self.arguments addObjectsFromArray:filenames];
    

    Again, being consistent in using properties rather than directly accessing instance variables will help you avoid these kinds of errors. So rewrite the previous line to use the property, like so:

    self.arguments = [NSMutableArray arrayWithObjects:@"-P", [password stringValue], [output stringValue], nil];
    

    The compiler translates self.arguments = someArg into [self setArguments:someArg]. In this case the setter method is needed to retain the object so that it won’t be deallocated while the reference is still stored in the _arguments instance variable.

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

Sidebar

Related Questions

I need add a new user group for mediawiki. The new group has more
I have the following code that I need to add an additonal object to
I am using AutoMapper to map objects from a legacy database to a new
I need to delete some objects from an ArrayList if they meet a condition
I have a UITableView that updates from a NSFetchedResultsController . The UITableView has alternating
I've looped through an NSArray of NSDictionary objects that contain the data for several
I'm in VS2008 with Entity Framework. I'm accessing objects from the database using esql
I need to create a phonegap plugin for ios which fetches all artists from
I need to dynamically create a Video object in ActionScript 2 and add it
need to add a 2nd css stylesheet to a page. do i add a

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.