Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Sergio10

macrumors regular
Original poster
Oct 3, 2007
137
0
Hi,

I can't copy plist into the Documents folder.
Here is a code I developed:
PHP:
	NSBundle *bundle = [NSBundle mainBundle];
	NSError *error = nil;
	NSString *userSettingsPath = [bundle pathForResource:USER_SETTINGS_PLIST_NAME ofType:@"plist"];
	
	NSFileManager *fileManager = [NSFileManager defaultManager];

	// get "Documents" folder
	NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectoryPath = [searchPaths objectAtIndex:0];
	
	[fileManager copyItemAtPath:userSettingsPath toPath:documentsDirectoryPath error:&error];
Could you please find the issue?

Thanks
 
You are trying to copy the plist to the wrong path: you need to append the name of the file (in the target folder) to the folder itself.

So lets say your plist is called settings.plist. You are doing something like (as a Unix command)
Code:
cp /path/to/my/bundle/Resources/Settings.plist /path/to/docs/folder

Whereas you need

Code:
cp /path/to/my/bundle/Resources/Settings.plist /path/to/docs/folder/Settings.plist
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.