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-29 19:32:47


--- 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 :
> >
> > > --- In iolanguage%40yahoogroups.com">iolanguageyahoogroups.com, Quentin Mathé
gnustep-quentin
> > > wrote:
&gt; > > >
> > > > Le 27 oct. 06 à 19:17, Quentin Mathé a écrit :
> > >
> > > > How do I proceed to add new slots which aren't methods but
rather
> > > > instance variables?
> > > >
> > > > I tried without success:
> > > >
> > > > NSObject newSubclassNamed:(&quot;Controller") do(
> > > > setTableView: := method(sender, self tableView := sender)
&gt; > > > setWindow: := method(sender, self window := sender)
&gt; > > > myVar := "whatever"
> > > > )
> > > >
> > > > I replaced myVar := "whatever" by a setSlot, updateSlot or
newSlot
> > > > call without success either. Another thing I tried is to put in
> the
> > > > slot an NSString or a nil value rather an Io string.
&gt; > > > Is this problem related to the fact we cannot add instance
> variables
> > > > on the fly on Objc side?
>; > >
> > > I had added a method to create instance variable from Io side, but
i
&gt; > > finally removed it because i thought it could be problematic for
the
> > > heritage on the Objective-C side.
>; >
> > ok.
> >
> > > An Objective-C object allocates memory for its instance variables
> and
> > > its ancestors instance variables, so what would happen if you
added
> an
> > > instance variable to an ancestors ? That's why categories don't
>; allow
>; > > extra variables either.
&gt; >
> > But at the time you create the subclass, I think you can create
&gt; > whatever instance variables you need and pass them by adding a new
> > parameter to newSubclassNamed. Then the runtime call in charge of
> > subclassing will take care of them. However it won't be possible to
> > create new slots/ivars later or in another way as it's common with
> > Io. What do you think?
&gt; >
> > > 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.
>; > Another thing which might work well is… Declaring an Objc class
>; named
>; > AbstractController which includes ivar declartions in its interface.
> > Then calling AbstractController newSubclassNamed:(&quot;Controller") do
> > (... In this case, the outlets would be inherited from the
superclass.
>; >
> > I have a last question. What is the best way to link/load an Objc
> > framework? By linking it in a bundle and loading the bundle?
&gt; >
> > Thanks,
&gt; > Quentin.
> >
> > --
> > Quentin Mathé
>; > qmathe
> >
>
> 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.
>
&gt; For your last question, well, i'm not sure to get what you want, do
you
&gt; want to load non GNUstep Objective-C code ? If so, bundle loading
should
> do the trick, else you could hack the ObjcBridge build.io and add the
> dependsOnLib/dependsOnFramework line you need. 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
&gt; or a script like in
> http://www.etoile-project.org/etoile/blog/2006/09/io-and-gnustep.html
?
>

It might also be cleaner to declare instance variables in the init
method

NSObject newSubclassNamed:(&quot;Controller") do(
setTableView: := method(sender, self tableView := sender)
setWindow: := method(sender, self window := sender)
init := method(self = super(init) ; self _myVar := "whatever" ;
self)
myVar := method(_myVar)
setMyVar: := method(value, _myVar = value)
)

__._,_.___
.

__,_._,___
[1]

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