• 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
Document-based apps in ASObjC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Document-based apps in ASObjC


  • Subject: Document-based apps in ASObjC
  • From: Shane Stanley <email@hidden>
  • Date: Wed, 30 Dec 2009 08:53:13 +1100
  • Thread-topic: Document-based apps in ASObjC

I'm trying to make sense of using an NSDocument subclass in ASObjC.

If I start a new document-based project, MyDocument.applescript contains,
among other things:

    on readFromData_ofType_error_(data, typeName, outError)
[...]
        if outError is not missing value then
            set contents of outError to my NSError's
errorWithDomain_code_userInfo_(my NSOSStatusErrorDomain, my unimpErr,
missing value)
        end if
        return true
    end readFromData_ofType_error_

Now that can't work. You can't use data as a variable name, NSError isn't
declared anywhere, and the two "my"s should be "current application's". But
I'm wondering if there's any point fixing it at all, or is support for
NSError ** parameters now available, and accessible some way by using
"contents of"?

OTOH, if you add a new file and select NSDocument, you get instead:

    on loadDataRepresentation_ofType_(|data|, typeName)
        -- Insert code here to read your document from the given data of the
specified type.  This method has been deprecated in favor of -[NSDocument
readFromData:ofType:error:], but AppleScript/Objective-C does not support
(NSError **) parameters yet, and this method is forward-compatible.
        return true
    end loadDataRepresentation_ofType_

So which is the real story? Should MyDocument.applescript contain the same
as the NSDocument subclass template?

And then there's the Cocoa question: Is this error ever used? Because when I
try something like this in Obj-C:

- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName
error:(NSError **)outError
{
    *outError = [self prepareError]; // makes an error
    return NO;
}

The error dialog contains nothing from outError anyway...

--
Shane Stanley <email@hidden>
AppleScript Pro, April 2010, Florida <http://www.applescriptpro.com>


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescriptobjc-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: How to debug or develop incrementally in ASObjC?
  • Next by Date: How do you split a script into multiple source files
  • Previous by thread: Re: How to debug or develop incrementally in ASObjC?
  • Next by thread: How do you split a script into multiple source files
  • Index(es):
    • Date
    • Thread