Re: ASObjC alloc and object creation
Re: ASObjC alloc and object creation
- Subject: Re: ASObjC alloc and object creation
- From: Shane Stanley <email@hidden>
- Date: Mon, 29 Jan 2018 15:12:35 +1100
On 29 Jan 2018, at 11:07 am, Jean-Christophe Helary
<email@hidden> wrote:
>
> So basically I can use the "convenience method" documentWithRootElement on
> it to do the same thing as my original code:
>
> set theProject to current application's NSXMLNode's
> documentWithRootElement:projectRoot
>
> set theProject to current application's NSXMLDocument's alloc()'s
> initWithRootElement:projectRoot
That's right. Under the hood, the former is basically a wrapper around the
latter.
>
> Is that kind of mechanism dependent on whether I work with classes that are
> the base classes for a number of other classes?
Not really. NSDate is a good example -- "dateWithTimeIntervalSinceNow:" is the
same as "alloc()'s initTimeIntervalSinceNow:". Some classes have lots of
convenience methods, and others rely solely on initializers -- there's no
discernible pattern to it.
--
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden