Hi all,
I am trying to perform the following tasks with files, but I am stuck.
Here is the code:
NSString* aStr = @"Hello World!";
NSData* aData;
aData = [aStr dataUsingEncoding: NSASCIIStringEncoding];
NSFileManager *fileManager = [NSFileManager defaultManager];
//destination is NSString which Contains the absolute address
if ([fileManager fileExistsAtPath:destination])
{
NSLog(@"File Exists!");
}
else
{
BOOL statusOfFile=[fileManager createFileAtPath :destination contents:aData attributes:nil];
}
if(statusOfFile)
printf("\n\nFile Created!");
else
printf("\n\nError in File creation!");
I am not able to able to create a file - the value of statusOfFile
is NO
.
I tried this code in GNU and it works fine - the problem exists only with Xcode.
Can anybody tell me why?
Can anybody help? Thanks.