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

StijnSpijker

macrumors newbie
Original poster
Jan 27, 2009
5
0
The Netherlands
This is crazy :confused:

I simply want to write an NSString to file.
When I do this:

Code:
NSString *frameString = @"You're the banana king, Charlie!";
NSString *path = @"/Users/me/textFile.txt";
[frameString writeToFile:path atomically:YES];

All is fine, file get's written, no problems :)
Buuuut, this method has been deprecated by Apple since 10.4, you now need to specify the encoding, and optionally where you want to return errors.

So, the last line is replace by this one:
Code:
[frameString writeToFile:path atomically:YES encoding:NSUnicodeStringEncoding error:NULL];

And then, BAM, uncaught exception:

Code:
2009-07-04 01:47:44.315 iPhoneStreamingPlayer[50097:20b] *** -[NSConcreteData writeToFile:atomically:encoding:error:]: unrecognized selector sent to instance 0x1032000
2009-07-04 01:47:44.317 iPhoneStreamingPlayer[50097:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSConcreteData writeToFile:atomically:encoding:error:]: unrecognized selector sent to instance 0x1032000'

I'm really getting nuts, maybe it's getting too late :p
I tried several encodings (UTF8, ASCII even UTF16), they all spawn errors.
Any ideas?
 
Last edited:
This is crazy :confused:

I simply want to write an NSString to file.
When I do this:

Code:
NSString *frameString = @"You're the banana king, Charlie!";
NSString *path = @"/Users/me/textFile.txt";
[frameString writeToFile:path atomically:YES];

All is fine, file get's written, no problems :)
Buuuut, this method has been deprecated by Apple since 10.4, you now need to specify the encoding, and optionally where you want to return errors.

So, the last line is replace by this one:
Code:
[frameString writeToFile:path atomically:YES encoding:NSUnicodeStringEncoding error:NULL];

And then, BAM, uncaught exception:

Code:
2009-07-04 01:47:44.315 iPhoneStreamingPlayer[50097:20b] *** -[NSConcreteData writeToFile:atomically:encoding:error:]: unrecognized selector sent to instance 0x1032000
2009-07-04 01:47:44.317 iPhoneStreamingPlayer[50097:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSConcreteData writeToFile:atomically:encoding:error:]: unrecognized selector sent to instance 0x1032000'

I'm really getting nuts, maybe it's getting too late :p
I tried several encodings (UTF8, ASCII even UTF16), they all spawn errors.
Any ideas?

Okay, sorry, it was just getting late, I fixed the problem.
You couldn't actually derive it from what I showed you here, but in fact the NSString was retrieved from some other class, but it turned it that wasn't an NSString, but NSMutableData... I casted it wrong, then ofcourse from there everything went wrong.

So if you get this error: Check whether you're actually handling the object you THINK you are handling.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.