Hi,
I'm new to Objective C (really only started yesterday), and I'm currently trying to make a simple program to copy a directory to a destination (or multiple destinations). I've done all the fun stuff (interface builder, love it) but now its time for the file copy stuff...
Looking around on the internet on blogs and things I have discovered that file copying isn't one of Cocoa's strong points (well, at least easily). I found out that I can use system() commands which I could call to get the job done, I also found the NSFileManager's copyItemAtPath toPath function. Both of these ways work, but they all seem to pause the entire program and even makes Mac OSX think the program is not responding. Due to the size of the directories I am wanting to use this program for, this isn't really what I want, especially as I want to have a spinning progress indicator running (because I am new to programming on the Mac and I think these are awesome! I've given up dreams of having a real progress indicator for now, these seem to be the next step).
I heard that this is because they are doing it synchronously, and that I need something asynchronously. I also found this here, http://www.cimgf.com/2008/05/03/cocoa-tutorial-file-copy-with-progress-indicator/, which is using FSCopyObjectAsync - apparently a Cocoa function which has memory leak issues, plus I'm not even sure if you can copy entire directories like this. I'm not sure how to get this one running, and if I should even use it for my program.
So is there any way to use native Cocoa to copy a file in the background or something, to keep the program from completely not responding and beach-balling, or do I have to try and figure out how to use something old and annoying like FSCopyObjectAsync, if I do, how do I use this for entire directories?
Thanks for your help and I hope you can help me out.
Jordan
I'm new to Objective C (really only started yesterday), and I'm currently trying to make a simple program to copy a directory to a destination (or multiple destinations). I've done all the fun stuff (interface builder, love it) but now its time for the file copy stuff...
Looking around on the internet on blogs and things I have discovered that file copying isn't one of Cocoa's strong points (well, at least easily). I found out that I can use system() commands which I could call to get the job done, I also found the NSFileManager's copyItemAtPath toPath function. Both of these ways work, but they all seem to pause the entire program and even makes Mac OSX think the program is not responding. Due to the size of the directories I am wanting to use this program for, this isn't really what I want, especially as I want to have a spinning progress indicator running (because I am new to programming on the Mac and I think these are awesome! I've given up dreams of having a real progress indicator for now, these seem to be the next step).
I heard that this is because they are doing it synchronously, and that I need something asynchronously. I also found this here, http://www.cimgf.com/2008/05/03/cocoa-tutorial-file-copy-with-progress-indicator/, which is using FSCopyObjectAsync - apparently a Cocoa function which has memory leak issues, plus I'm not even sure if you can copy entire directories like this. I'm not sure how to get this one running, and if I should even use it for my program.
So is there any way to use native Cocoa to copy a file in the background or something, to keep the program from completely not responding and beach-balling, or do I have to try and figure out how to use something old and annoying like FSCopyObjectAsync, if I do, how do I use this for entire directories?
Thanks for your help and I hope you can help me out.
Jordan