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

|
2006-10-29 09:49:44 |
|
__,_._,___
|
| How to use nib outlets/connections with
Objective-C bridge |

|
2006-10-29 11:39:54 |
|
--- In iolanguage%40yahoogroups.com">iolanguage yahoogroups.com, Quentin Mathé <gnustep-quentin ...>
wrote:
>
> Le 27 oct. 06 à 19:17, Quentin Mathé a écrit :
> > Le 19 oct. 06 à 12:04, baptisteheyman a écrit :
> >
> > > --- In iolanguage%40yahoogroups.com">iolanguage yahoogroups.com, Quentin Mathé <gnustep-
> > quentin >
> > > wrote:
> > > >
> > > > I would like to know whether it's currently possible to access
> > > > outlets created in a nib from Io code.
> > >
> > > You can with an Io controller.
> > >
> > > For example that interface :
> > >
> > > interface Controller : NSObject
> > > {
> > > id tableView;
> > > id window;
> > > }
> > >
> > > should be replaced by that object :
> > >
> > > NSObject newSubclassNamed:("Controller") do(
> > > setTableView: := method(sender, self tableView := sender)
> > > setWindow: := method(sender, self window := sender)
> > > )
> >
> > Thanks for the reply. I just tried it today and it works well. Going
> > to try more stuff.
> How do I proceed to add new slots which aren't methods but rather
> instance variables?
>
> I tried without success:
>
> NSObject newSubclassNamed:("Controller") do(
> setTableView: := method(sender, self tableView := sender)
> setWindow: := method(sender, self window := sender)
> 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.
> Is this problem related to the fact we cannot add instance variables
> on the fly on Objc side?
>
> Cheers,
> Quentin.
>
> --
> Quentin Mathé
> qmathe ...
>
I had added a method to create instance variable from Io side, but i
finally removed it because i thought it could be problematic for the
heritage on the Objective-C side.
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.
To make your Io variable visible on the Objective-C side you could
just add getter/setter methods.
NSObject newSubclassNamed:("Controller") do(
setTableView: := method(sender, self tableView := sender)
setWindow: := method(sender, self window := sender)
_myVar := "whatever"
myVar := method(_myVar)
setMyVar: := method(value, _myVar = value)
)
Hope that helps.
__._,_.___
.
__,_._,___
|
| How to use nib outlets/connections with
Objective-C bridge |

|
2006-10-29 11:39:54 |
|
--- In iolanguage%40yahoogroups.com">iolanguage yahoogroups.com, Quentin Mathé <gnustep-quentin ...>
wrote:
>
> Le 27 oct. 06 à 19:17, Quentin Mathé a écrit :
> > Le 19 oct. 06 à 12:04, baptisteheyman a écrit :
> >
> > > --- In iolanguage%40yahoogroups.com">iolanguage yahoogroups.com, Quentin Mathé <gnustep-
> > quentin >
> > > wrote:
> > > >
> > > > I would like to know whether it's currently possible to access
> > > > outlets created in a nib from Io code.
> > >
> > > You can with an Io controller.
> > >
> > > For example that interface :
> > >
> > > interface Controller : NSObject
> > > {
> > > id tableView;
> > > id window;
> > > }
> > >
> > > should be replaced by that object :
> > >
> > > NSObject newSubclassNamed:("Controller") do(
> > > setTableView: := method(sender, self tableView := sender)
> > > setWindow: := method(sender, self window := sender)
> > > )
> >
> > Thanks for the reply. I just tried it today and it works well. Going
> > to try more stuff.
> How do I proceed to add new slots which aren't methods but rather
> instance variables?
>
> I tried without success:
>
> NSObject newSubclassNamed:("Controller") do(
> setTableView: := method(sender, self tableView := sender)
> setWindow: := method(sender, self window := sender)
> 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.
> Is this problem related to the fact we cannot add instance variables
> on the fly on Objc side?
>
> Cheers,
> Quentin.
>
> --
> Quentin Mathé
> qmathe ...
>
I had added a method to create instance variable from Io side, but i
finally removed it because i thought it could be problematic for the
heritage on the Objective-C side.
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.
To make your Io variable visible on the Objective-C side you could
just add getter/setter methods.
NSObject newSubclassNamed:("Controller") do(
setTableView: := method(sender, self tableView := sender)
setWindow: := method(sender, self window := sender)
_myVar := "whatever"
myVar := method(_myVar)
setMyVar: := method(value, _myVar = value)
)
Hope that helps.
__._,_.___
.
__,_._,___
|
[1-3]
|
|