• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSDocument window opens - even if the document didn't read properly.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSDocument window opens - even if the document didn't read properly.


  • Subject: NSDocument window opens - even if the document didn't read properly.
  • From: Pascal Harris <email@hidden>
  • Date: Sun, 29 Jul 2012 18:53:16 +0100

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@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

  • Follow-Ups:
    • Re: NSDocument window opens - even if the document didn't read properly.
      • From: Mike Abdullah <email@hidden>
  • Prev by Date: Re: How to anchor a child-window to its parent top-right (or other point) while parent resizes.
  • Next by Date: Re: occasional crash when closing app document: forwardMethod?
  • Previous by thread: Re: occasional crash when closing app document: forwardMethod?
  • Next by thread: Re: NSDocument window opens - even if the document didn't read properly.
  • Index(es):
    • Date
    • Thread