• 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
Overridden NSObject class cannot get instance properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Overridden NSObject class cannot get instance properties


  • Subject: Overridden NSObject class cannot get instance properties
  • From: Dave <email@hidden>
  • Date: Tue, 11 Jan 2011 14:21:04 -0600

I often override the NSObject description method to customize the display of a class or instance, but this is not working in ASOC. That method can never access its instance properties.  Example code.

script TestInstancePropsNeedObjToSetAppDelegate
property parent : class "NSObject"


on applicationWillFinishLaunching_(aNotification)


set theObj1 to current application's Test1's makeTest1__("TEST1a", "TEST1b")
set theObj2 to current application's Test1's makeTest1__("TEST2a", "TEST2b")
theObj1's DisplayMe()
theObj2's DisplayMe()
log "--------------"
theObj1's |description|()
theObj2's |description|()


current application's NSApp's terminate_(me)
end applicationWillFinishLaunching_


on applicationShouldTerminate_(sender)
return current application's NSTerminateNow
end applicationShouldTerminate_


end script


script Test1
property classProp : missing value
property instProp1 : missing value
property instProp2 : missing value


on makeTest1__(val1, val2)
set my classProp to "CLASS VALUE"
set my instProp1 to "CLASS VALUE1 FOR INSTANCE"
set my instProp2 to "CLASS VALUE2 FOR INSTANCE"
set newObj1 to current application's Test1's alloc()'s init()
set newObj1's instProp1 to val1 as string
newObj1's InitMe_(val2)
return newObj1
end makeTest1__


on InitMe_(aVal)
set instProp2 to aVal as string
end InitMe_


on DisplayMe()
log "DisplayMe()  my classProp: " & my classProp & ", my instProp1: " & my instProp1 & ", my instProp2: " & my instProp2
end DisplayMe


on |description|()
log "description()  my classProp: " & my classProp & ", my instProp1: " & my instProp1 & ", my instProp2: " & my instProp2
end |description|


end script


The output is:

DisplayMe()  my classProp: CLASS VALUE, my instProp1: TEST1a, my instProp2: TEST1b
DisplayMe()  my classProp: CLASS VALUE, my instProp1: TEST2a, my instProp2: TEST2b
--------------
description()  my classProp: CLASS VALUE, my instProp1: CLASS VALUE1 FOR INSTANCE, my instProp2: CLASS VALUE2 FOR INSTANCE
description()  my classProp: CLASS VALUE, my instProp1: CLASS VALUE1 FOR INSTANCE, my instProp2: CLASS VALUE2 FOR INSTANCE


-- dave




-- Dave

 _______________________________________________
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

  • Follow-Ups:
    • Re: Overridden NSObject class cannot get instance properties
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: Can't invoke NSApplication's terminate
  • Next by Date: Re: Overridden NSObject class cannot get instance properties
  • Previous by thread: Re: Can't invoke NSApplication's terminate
  • Next by thread: Re: Overridden NSObject class cannot get instance properties
  • Index(es):
    • Date
    • Thread