Re: Dynamic framework loading and properties
Re: Dynamic framework loading and properties
- Subject: Re: Dynamic framework loading and properties
- From: "email@hidden" <email@hidden>
- Date: Sun, 12 Dec 2010 09:55:11 +0000
On 12 Dec 2010, at 03:39, Shane Stanley wrote:
> On 12/12/10 9:01 AM, "email@hidden" <email@hidden>
> wrote:
>
>> Any ideas?
>
> My *guess* would be that that's just the way it works. Not very helpful, I
> know...
>
Thanks for the reply Shane.
I thought perhaps there was wrinkle in the syntax that I was missing.
Most of the other ObjC bridges handle framework loading better (see examples below).
I imagine that ASObjC uses the scripting bridge to pull in the property references.
Certainly this is what the other like bridges like JSCocoa do when they explicitly load a framework.
Just loading the bundle using NSBundle won't, I think, achieve this (though F-Script manages to pull the trick off - it's ObjC based though to begin with).
The question remains though why it works for statically linked frameworks.
Perhaps the bridge explicitly processes them at startup.
Or perhaps there is something significant in the property AddressBook : class "ABAddressBook" call.
This only seems to work for statically linked frameworks as the property dec is evaluated before variables are assigned, meaning. I think, that you can't get the framework loaded dynamically before the property.
Anyhow,
NSBundle's bundleWithPath_("/System/Library/Frameworks/AddressBook.framework")'s load
is still useful as it stands.
We will probably have to await the evolution of some explicit framework loading syntax before full framework manipulation lies before us.
Regards
Jonathan Mitchell
Developer
Mugginsoft LLP
http://www.mugginsoft.com
========= > F-script
[
"load the addressbook framework"
(NSBundle bundleWithPath:'/System/Library/Frameworks/AddressBook.framework') load.
" access the me object in the shared address book "
person := ABAddressBook sharedAddressBook me.
" get the first name property "
firstName := person valueForProperty:kABFirstNameProperty.
firstName
]
========= > JSCocoa
// load the AddressBook framework
loadFramework("AddressBook")
function kosmicTask()
{
// access the me object in the shared address book
var person = ABAddressBook.sharedAddressBook.me
// get the first name property
result = person.valueForProperty(kABFirstNameProperty)
return result
}
========= > LuaCocoa
LuaCocoa.import("AddressBook")
function kosmicTask()
local person = ABAddressBook:sharedAddressBook():me()
return person:valueForProperty_(kABFirstNameProperty)
end
========= > PyObjC
# import our system framework by name
import AddressBook
def kosmictask():
person = AddressBook.ABAddressBook.sharedAddressBook().me()
firstName = person.valueForProperty_(AddressBook.kABFirstNameProperty)
# return object
return firstName
========= > RubyCocoa
require 'osx/cocoa'
OSX.require_framework "AddressBook"
def kosmictask()
person = OSX::ABAddressBook.sharedAddressBook().me()
firstName = person.valueForProperty_(OSX::KABFirstNameProperty)
return firstName
end
Regards
Jonathan Mitchell
Developer
Mugginsoft LLP
http://www.mugginsoft.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