Hai Guys,
I'm having a bit of an issue here..
I'm trying to implement file sharing via iTunes in 2 projects.
One goes like this -> you drag an picture in iTunes, and on every App resume you will copy them to a special made folder in the NSLibrary, because apparently Apple started rejecting apps for writing to the NSDocument folder.
In another project, I want to be able to save something from the iPhone itself to the file sharing, so you can take it off via iTunes..
But since this has changes (the way to do it), I can't really find good tutorials or so.
ATM I have something like this in the App resume:
And for now i'm coming up with an blank image..
For the second project, with the other way around i'm a bit blind atm, hope someone can shed a light at it.
Greetings, Noxx
I'm having a bit of an issue here..
I'm trying to implement file sharing via iTunes in 2 projects.
One goes like this -> you drag an picture in iTunes, and on every App resume you will copy them to a special made folder in the NSLibrary, because apparently Apple started rejecting apps for writing to the NSDocument folder.
In another project, I want to be able to save something from the iPhone itself to the file sharing, so you can take it off via iTunes..
But since this has changes (the way to do it), I can't really find good tutorials or so.
ATM I have something like this in the App resume:
Code:
NSMutableArray *retval = [NSMutableArray array];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *publicDocumentsDir = [paths objectAtIndex:0];
NSError *error;
NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:publicDocumentsDir error:&error];
if (files == nil) {
NSLog(@"Error reading contents of documents directory: %@", [error localizedDescription]);
} else {
for (NSString *file in files) {
if ([file.pathExtension compare:@"png" options:NSCaseInsensitiveSearch] == NSOrderedSame) {
NSString *fullPath = [publicDocumentsDir stringByAppendingPathComponent:file];
[retval addObject:fullPath];
}
}
}
NSError *error2 = nil;
NSArray *libPath = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *libraryDirectory = [libPath objectAtIndex:0];
NSString *iconpath = [libraryDirectory stringByAppendingFormat:@"/test.png"];
NSURL *iconURL = [NSURL fileURLWithPath:iconpath];
NSLog(@"iconURL: %@", iconURL);
//NSArray *iconFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:iconPath error:nil];
for (int i = 0; i < [retval count]; i++) {
NSString *file = [retval objectAtIndex:i];
NSURL *url = [NSURL fileURLWithPath:file];
if ([file.pathExtension compare:@"png" options:NSCaseInsensitiveSearch] == NSOrderedSame) {
BOOL succes = [[NSFileManager defaultManager] copyItemAtURL:url toURL:iconURL error:&error2];
if (succes) {
NSLog(@"it worked, copied file");
} else {
NSLog(@"error2: %@", [error2 localizedDescription]);
}
}
}
And for now i'm coming up with an blank image..
For the second project, with the other way around i'm a bit blind atm, hope someone can shed a light at it.
Greetings, Noxx