Objective-C - GNUstep NSData writeToFile error on Windows

by zebsadiq 4. February 2011 11:40

If you’re trying to get going with GNUstep, you follow all of the instructions but you come accross the following message:

File NSData.m:1413 In[NSData writeToFile.options:error:] Open (/home/USER/ProjectFolder/Filenamea12345) failed – The system cannot find the file specified.

FilePathFailure

This error is caused because the path can really not be found. I discovered that you need the full windows path to the file including ‘c:/’ . This was a little confusing at first but it does make sense. Remember that you’ll need to user forward slashes (‘/’) rather than back slashes.  The working code becomes:

int main(void)
{
	CREATE_AUTORELEASE_POOL(pool);
	NSString *filename = @"C:/GNUstep/home/z.sadiq/ObjectiveC/test.txt";
	NSString *name = @"This string was created by GNUstep";

	if([name writeToFile:filename atomically:YES])
	{	
		NSLog(@"Success");	
	}
	else	
	{
		NSLog(filename); 
		NSLog(@"Failure");
	}
	RELEASE(pool);
	return 0;
}

Tags: ,

Objective-C

Comments

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading



Calendar

<<  October 2019  >>
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

View posts in large calendar