Document file read, but -readFromData:(etc) has error.
Document file read, but -readFromData:(etc) has error.
- Subject: Document file read, but -readFromData:(etc) has error.
- From: John Velman <email@hidden>
- Date: Thu, 13 Aug 2009 14:07:36 -0700
- Mail-followup-to: John Velman <email@hidden>, Cocoa Development <email@hidden>
I'm writing a simple throw away program to transform data format from a
text file to a text file. I decided to use a Cocoa Document class for
practice, instead of (for example) perl.
Using -readFromData:ofType:Error: storing the data as a string, and then
converting the string works fine (except the program just stalls
afterwards) and has to be killed.
In trying to track this down, I put a bunch of NSLog's in, and ended up
with this (boiler plate comments ommitted):
__
- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError
{
NSLog(@"readFromData has been called, typeName is: %@\n", typeName);
if ( outError != NULL ) {
NSLog(@"outError is not null");
NSLog(@"Going to call NSError\n");
*outError = [NSError errorWithDomain:NSOSStatusErrorDomain
code:unimpErr userInfo:NULL];
NSLog(@"Read error -- outError is: %@\n\n", *outError);
[self setInputData:[[NSString alloc]
initWithData:data encoding:NSUTF8StringEncoding]];
[self convertData];
return NO;
}
"convertData" is the method that does the format conversion. It has ample
NSLog statments so I can see that it is being converted properly.
My debug console gives:
2009-08-13 13:44:50.376 TransformKaiser[1419:10b] readFromData has been called, typeName is: Kiaser History Convert
2009-08-13 13:44:50.378 TransformKaiser[1419:10b] outError is not null
2009-08-13 13:44:50.378 TransformKaiser[1419:10b] Going to call NSError
2009-08-13 13:44:50.380 TransformKaiser[1419:10b] Read error -- outError is: Error Domain=NSOSStatusErrorDomain Code=-4 "Operation could not be completed. (OSStatus error -4.)" ( / / unimplemented core routine)
(Could have spelled Kaiser correctly, but what the heck, this was supposed
to be a one run throw away program.)
and I get an alert message that says: "The document “testFile.txt” could
not be opened." I suppose this is due to returning NO.
But what is the unimplemented core routine?
I'm using Xcode 3.1.3, on OS X 10.5.8, Intel core 2 duo. My active
architecture is i386, sdk is 10.5, build configuration is Debug.
Thanks,
John Velman
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden