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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:05:50+00:00 2026-05-27T22:05:50+00:00

I am new to objective-c. I’ve taken classes in both python and c++, but

  • 0

I am new to objective-c. I’ve taken classes in both python and c++, but am really interested in objective-c so I’ve been working on learning on my own the last couple of days. This program is supposed to compare files in two locations and add missing ones. A simple sync, although not all features are currently implemented.

The error arrises from the recursivelyGetContentsOfDirectory function. It is returning the error EXEC_BAD_ACCESS. Since it’s not actually in the function I’m assuming that it’s something to do with how it’s defined.

   #import <AppKit/AppKit.h>

@interface Sync : NSControl{
    NSURL *baseToDirectory;
    NSURL *baseFromDirectory;

    NSArray *filesInBaseFromDirectory;

    IBOutlet NSTextField *baseToDirectoryLabel;
    IBOutlet NSTextField *baseFromDirectoryLabel;
}
- (IBAction)chooseBaseSyncFromDirectory:(id)sender;
- (IBAction)chooseBaseSyncToDirectory:(id)sender;
- (IBAction)performSync:(id)sender;

void recursivelyGetContentsOfDirectory (NSURL *path);

@end

implementation file

#import "Sync.h"

@implementation Sync


- (IBAction)chooseBaseSyncFromDirectory:(id)sender {

    NSOpenPanel* openDlg = [NSOpenPanel openPanel];
    [openDlg setCanChooseDirectories:YES];
    [openDlg setCanChooseFiles:NO];
    //Open the directory
    if ([openDlg runModal] == NSFileHandlingPanelOKButton) {
        NSArray *files = [openDlg URLs];
        NSString *fileAsString = [[files objectAtIndex:0] path];
        [baseFromDirectoryLabel setStringValue:fileAsString];
        baseFromDirectory = [files objectAtIndex:0];
        recursivelyGetContentsOfDirectory(baseFromDirectory);
    }
}

- (IBAction)chooseBaseSyncToDirectory:(id)sender {
    NSOpenPanel* openDlg = [NSOpenPanel openPanel];
    [openDlg setCanChooseDirectories:YES];
    [openDlg setCanChooseFiles:NO];

    if ([openDlg runModal] == NSFileHandlingPanelOKButton) {
        NSArray *files = [openDlg URLs];
        NSString *fileAsString = [[files objectAtIndex:0] path];
        [baseToDirectoryLabel setStringValue:fileAsString];
        baseToDirectory = [files objectAtIndex:0];
    }
}

void recursivelyGetContentsOfDirectory (NSURL *path){
    NSFileManager *tempManager;
    NSArray *contentsOfDirectory = [tempManager contentsOfDirectoryAtPath:[path path] error:nil];
    for (int i = 0; i < (int)[contentsOfDirectory count] ; i = i+1) {
        if ([[contentsOfDirectory objectAtIndex:i] isDirectory]) {
            NSString *next = [NSString stringWithString:[path path]];
            [next stringByAppendingString:[contentsOfDirectory objectAtIndex:i]];
            NSURL *nextPath = [NSURL URLWithString:next];
            recursivelyGetContentsOfDirectory(nextPath);
        } else {
            NSLog(@"Non-Directory Found");
        }
    }
}

- (IBAction)performSync:(id)sender {

}

@end
  • 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-27T22:05:50+00:00Added an answer on May 27, 2026 at 10:05 pm
    NSFileManager *tempManager;
    

    You are not creating the tempManager

    it should be something like

    NSFileManager *tempManager=[[NSFileManager alloc] init];
    

    if you are not using ARC, you are responsible to (auto)release tempManager.

    or use NSFileManager *tempManager = [NSFileManager defaultManager]

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

Sidebar

Related Questions

Im new to objective-c and I've been reading up on singleton classes. I want
I'm relatively new to Objective-C and really don't know much about it yet, so
New to Objective-C iPhone/iPod touch/iPad development, but I'm starting to discover lots of power
Very new to Objective-C and Xcode and working my way through modifying the DrillDownApp
(New to Objective-C, but well versed in C/C++). Presently I have an Objective-C class
First of all, I am a a very new Objective C/Cocoa iOS Developer but
I am new to Objective-C. I am currently working on a game using Cocos2D
I'm new to Objective-C 2.0, but very familiar with C++. In C++ I would
I'm pretty new to Objective-C and I'm working on a webradio app. My app
I'm new to Objective-c, so sorry if I'm missing something really obvious. I'm currently

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.