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

<<  December 2024  >>
MoTuWeThFrSaSu
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

View posts in large calendar