Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to add objects from an NSArray to the end of an NSMutableArray?
    text
    copied!<p>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 <code>[NSMutableArray addObjectsFromArray:NSArray]</code> and that keeps giving me an error.</p> <p>This is what I'm doing with the code: AppDelegate.h</p> <pre><code>#import &lt;Cocoa/Cocoa.h&gt; @interface ZipLockAppDelegate : NSObject &lt;NSApplicationDelegate&gt; { 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 </code></pre> <p>AppDelegate.m</p> <pre><code>#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]; } </code></pre> <p>And this is the error I keep getting in the log. I can't figure out why I'm getting this.</p> <pre><code>EXC_BAD_ACCESS(code=13,address=0x0) </code></pre> <p>This points to the line <code>[arguments addObjectsFromArray:filenames];</code></p> <p>I can only make out the first part about the selector and the instance but I don't know what it means. Help...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload