I hope that someone here might be able to help me with a couple of queries.
1. I'm trying to open a document (NSDocument). If the file is good then my
program opens it without problem. If the document fails to parse correctly
then the NSDocument window still opens - but it opens empty. Of course, if
parsing of the document fails then I want the document window not to open at
all. The document data gets read as so and if it fails then I return NO - the
document window still opens though. Can anyone suggest what I might have
missed or messed up?
- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError
**)outError
{
BOOL success = NO;
success = [self loadTextViewWithInitialData: data];
if (!success)
{
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory,
NSUserDomainMask, YES);
NSString* URLString = [[[paths objectAtIndex:0]
stringByAppendingString:[self
fileURL].lastPathComponent]stringByAppendingString:@".bad"];
NSURL* destinationURL = [NSURL URLWithString:[URLString
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
BOOL success = [[NSFileManager defaultManager] copyItemAtURL:[self
fileURL] toURL:destinationURL error:nil];
}
return success;
}
2. If the document fails to open then I want to copy it to a new location,
with a new extension (see above). This fails. I can't think why!
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]