List Info

Thread: How to use nib outlets/connections with Objective-C bridge




How to use nib outlets/connections with Objective-C bridge
user name
2006-10-30 09:22:06

Le 29 oct. 06 à 20:32, baptisteheyman a écrit :
> --- In iolanguage%40yahoogroups.com">iolanguageyahoogroups.com, "baptisteheyman"
> <baptisteheyman...>
> wrote:
&gt; >
> >
> > --- In iolanguage%40yahoogroups.com">iolanguageyahoogroups.com, Quentin Mathé
>; > gnustep-quentin wrote:
&gt; > >
> > > Le 29 oct. 06 à 12:39, baptisteheyman a écrit :
> > > >
> > > > To make your Io variable visible on the Objective-C side you
> could
>; > > > just add getter/setter methods.
> > > >
> > > > NSObject newSubclassNamed:(&quot;Controller") do(
> > > > setTableView: := method(sender, self tableView := sender)
&gt; > > > setWindow: := method(sender, self window := sender)
&gt; > > > _myVar := "whatever"
> > > > myVar := method(_myVar)
> > > > setMyVar: := method(value, _myVar = value)
&gt; > > > )
> > >
> > > I will try that.
Well, this solution doesn't work. _myVar slot isn't created, I get
'slot not found error' for _myvar when I access myVar.
I succeedded by declaring myVar in init method somewhat as you
suggested in this mail. Here is my code:

Controller init := method(
self do(
_myVar := "blabla"
myVar := method(_myVar)
setMyVar: := method(value, _myVar = value)
)
)

&gt; Yes, we could just add instance variables at class creation, but how
> would you access them from Io then ? We still need getter/setter
methods
> so we're stuck unless we allow direct access to Objective-C instance
> variables. It is feasible, it was even implemented but it was
really not
> needed, sharing methods between Io and Objective-C is sufficient.

Direct access to instance vars could be helpful in some cases I think.

> For your last question, well, i'm not sure to get what you want,
do you
> want to load non GNUstep Objective-C code ?

Yes. Like GNUstep-based AddressBook framework to take an example.

> If so, bundle loading should
> do the trick, else you could hack the ObjcBridge build.io and add the
> dependsOnLib/dependsOnFramework line you need.

ok

> Anyway if your code
> declare an informal protocol (not compiler enforced methods) you
should
> add it at the end of IoObjcBridge.h and in
> IoObjcBridge_selectorEncoding. Do you want a standalone compiled
program
> or a script like in
> http://www.etoile-project.org/etoile/blog/2006/09/io-and-gnustep.html

Initially a script, I used Calc.app as a template to begin (in fact
it's a new application to be included in Étoilé project).

Got a new question. I have tried to implement a table view with a
data source, but I'm currently stumbling on passing a selector as a
parameter an Objc method when the method is called in Io code. Here
is my attempt to do it:

Controller awakeFromNib := method(
// a bunch of code

tableView setDoubleAction:(&quot;listViewDoubleClick:")
tableView setTarget:(self)
)

Controller listViewDoubleClick: := method(sender,
&quot;Doucle click!&quot; println
)

Io interpreter complains about "listViewDoubleClick:"; not being of
the correct type.

Quentin.

--
Quentin Mathé
qmathe%40club-internet.fr">qmatheclub-internet.fr

__._,_.___
.

__,_._,___
How to use nib outlets/connections with Objective-C bridge
user name
2006-10-30 10:25:04

--- In iolanguage%40yahoogroups.com">iolanguageyahoogroups.com, Quentin Mathé <gnustep-quentin...>
wrote:
>;
> Le 29 oct. 06 à 20:32, baptisteheyman a écrit :
> > --- In iolanguage%40yahoogroups.com">iolanguageyahoogroups.com, "baptisteheyman&quot;
> > <baptisteheyman>
>; > wrote:
&gt; > >
> > >
> > > --- In iolanguage%40yahoogroups.com">iolanguageyahoogroups.com, Quentin Mathé
>; > > gnustep-quentin wrote:
&gt; > > >
> > > > Le 29 oct. 06 à 12:39, baptisteheyman a écrit :
> > > > >
> > > > > To make your Io variable visible on the Objective-C side you
> > could
>; > > > > just add getter/setter methods.
> > > > >
> > > > > NSObject newSubclassNamed:(&quot;Controller") do(
> > > > > setTableView: := method(sender, self tableView := sender)
&gt; > > > > setWindow: := method(sender, self window := sender)
&gt; > > > > _myVar := "whatever"
> > > > > myVar := method(_myVar)
> > > > > setMyVar: := method(value, _myVar = value)
&gt; > > > > )
> > > >
> > > > I will try that.
>; Well, this solution doesn't work. _myVar slot isn't created, I get
> 'slot not found error' for _myvar when I access myVar.
&gt; I succeedded by declaring myVar in init method somewhat as you
> suggested in this mail. Here is my code:
>;
> Controller init := method(
&gt; self do(
> _myVar := "blabla"
&gt; myVar := method(_myVar)
> setMyVar: := method(value, _myVar = value)
&gt; )
> )
>
> > Yes, we could just add instance variables at class creation, but how
> > would you access them from Io then ? We still need getter/setter
> methods
&gt; > so we're stuck unless we allow direct access to Objective-C instance
> > variables. It is feasible, it was even implemented but it was
> really not
> > needed, sharing methods between Io and Objective-C is sufficient.
>
> Direct access to instance vars could be helpful in some cases I think.
&gt;
> > For your last question, well, i'm not sure to get what you want,
> do you
> > want to load non GNUstep Objective-C code ?
>
> Yes. Like GNUstep-based AddressBook framework to take an example.
>
> > If so, bundle loading should
&gt; > do the trick, else you could hack the ObjcBridge build.io and add the
> > dependsOnLib/dependsOnFramework line you need.
>;
> ok
>
> > Anyway if your code
> > declare an informal protocol (not compiler enforced methods) you
> should
&gt; > add it at the end of IoObjcBridge.h and in
> > IoObjcBridge_selectorEncoding. Do you want a standalone compiled
> program
&gt; > or a script like in
> > http://www.etoile-project.org/etoile/blog/2006/09/io-and-gnustep.html
>
> Initially a script, I used Calc.app as a template to begin (in fact
> it's a new application to be included in Étoilé project).
>
> Got a new question. I have tried to implement a table view with a
> data source, but I'm currently stumbling on passing a selector as a
> parameter an Objc method when the method is called in Io code. Here
> is my attempt to do it:
>
> Controller awakeFromNib := method(
&gt; // a bunch of code
>
> tableView setDoubleAction:(&quot;listViewDoubleClick:")
> tableView setTarget:(self)
>; )
>
> Controller listViewDoubleClick: := method(sender,
> "Doucle click!&quot; println
&gt; )
>
> Io interpreter complains about "listViewDoubleClick:"; not being of
> the correct type.
>;
> Quentin.
>
> --
> Quentin Mathé
>; qmathe...
>

Sorry for the slot problem, I realised afterward it would not work so
I modified my previous message to introduce another method slightly
before you answered.

On the "listViewDoubleClick:"; not being of the correct type problem, I
don't have enough code to work it out, could you mail/paste me a
"working"; example ? Does the problem occur when you double click in a
tableView cell or is it directly at launch time ?

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )