• 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
Re: ASObjC alloc and object creation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ASObjC alloc and object creation


  • Subject: Re: ASObjC alloc and object creation
  • From: Jean-Christophe Helary <email@hidden>
  • Date: Mon, 29 Jan 2018 13:39:58 +0900

Also, I was trying to create an element with NSXMLNode's initWithKind like this:

set newElement to current application's NSXMLNode's alloc()'s
initWithKind:"NSXMLElementKind"

That doesn't work. I tried without alloc(), I tried with "Element", but that
did not work either.

So it looks like there is something in the Foundation documentation that I'm
not understanding properly (which is not a surprise :) but I'd really like to...

Jean-Christophe

> On Jan 29, 2018, at 9:07, Jean-Christophe Helary
> <email@hidden> wrote:
>
> Thank you Shane.
>
> The documentation for NSXMLNode says that it is the base class for
> "NSXMLElement, NSXMLDocument, NSXMLDTD, and NSXMLDTDNode". 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
>
> Is that kind of mechanism dependent on whether I work with classes that are
> the base classes for a number of other classes?
>
> Jean-Christophe
>
>> On Jan 28, 2018, at 22:02, Shane Stanley <email@hidden> wrote:
>>
>> On 28 Jan 2018, at 11:45 pm, Jean-Christophe Helary
>> <email@hidden> wrote:
>>>
>>> Why can I create an XML node without alloc ?
>>
>> It's what's known as a convenience method. You're actually making a
>> particular subclass of NSXMLNode, an NSXMLElement.
>>
>> You could have used:
>>
>> set projectRoot to current application's NSXMLElement's alloc()'s
>> initWithName:"omegat"
>>
>> But convenience methods are common, if not following any particular logic of
>> when and where they're provided. Something like "stringWithString:" instead
>> of "alloc()'s initWithString:" is a common example.
>>
>> In applications written using manual memory management, objects created by
>> init… methods have to be managed differently.
>>
>>
>> --
>> 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
>
> Jean-Christophe Helary
> -----------------------------------------------
> http://mac4translators.blogspot.com @brandelune
 _______________________________________________
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

  • Follow-Ups:
    • Re: ASObjC alloc and object creation
      • From: Shane Stanley <email@hidden>
References: 
 >ASObjC alloc and object creation (From: Jean-Christophe Helary <email@hidden>)
 >Re: ASObjC alloc and object creation (From: Shane Stanley <email@hidden>)
 >Re: ASObjC alloc and object creation (From: Jean-Christophe Helary <email@hidden>)

  • Prev by Date: Re: ASObjC alloc and object creation
  • Next by Date: Re: ASObjC alloc and object creation
  • Previous by thread: Re: ASObjC alloc and object creation
  • Next by thread: Re: ASObjC alloc and object creation
  • Index(es):
    • Date
    • Thread