How to access properties of the Gloabl object

Coding Questions, IDE related or anything else

How to access properties of the Gloabl object

Postby udo.killermann » Thu Jul 15, 2010 9:22 am

Hi Bernd,

hope you had a good holiday.
As I dig deeper into KVC I stumbled across another issue I cannot solve on my own:
Binding within Interface Builder only works for properties of objects already instantiated as such (Application, First Responder and Global). I have an array defined in my ukWindows class I want to bind to a table column which doesn't work cause I don't have an object of it to work in IB. So I thought I might define the array in Global and access it from my window instance at runtime. I have tried global.myArray or global!myArray (BTW: how does the ! operator work? didn't find an explanation within the documentation). These things compile, but throw an error in the link phase. How can I proceed?

Kind regards
Udo
--------------
MacBook (2GHz, 4 GByte) - Lion (10.7.3)
started Objective Basic coding in April 2010 - still enjoy it ;-)
udo.killermann
 
Posts: 247
Joined: Thu Apr 08, 2010 6:46 am
Location: Hannover, Germany

Re: How to access properties of the Gloabl object

Postby udo.killermann » Fri Jul 16, 2010 6:25 am

Bernd,

with the help of some experimentation I found out that I can do
Code: Select all
Declare Sub "GLOBAL" +(void)helloWord
and thus use GLOBAL.helloWorld() to call the method. Any official ways to do so?

And by the way: Bindings seem to be (at the moment) only possible for direct siblings of NSObject. As soon as I have this in place within IB it is possible to use this instance as the source for bindings - the same thing I observed for Global (see above).

Kind regards
Udo
--------------
MacBook (2GHz, 4 GByte) - Lion (10.7.3)
started Objective Basic coding in April 2010 - still enjoy it ;-)
udo.killermann
 
Posts: 247
Joined: Thu Apr 08, 2010 6:46 am
Location: Hannover, Germany

Re: How to access properties of the Gloabl object

Postby berndnoetscher » Fri Jul 16, 2010 10:44 am

Udo, please send me your example. It would speed up finding a solution. Thanks in advance.
berndnoetscher
Site Admin
 
Posts: 280
Joined: Fri Feb 20, 2009 11:58 am

Re: How to access properties of the Gloabl object

Postby udo.killermann » Sat Jul 17, 2010 11:44 am

Hi Bernd,

you'll find the working example attached to this post. What I basically do is setting up a window (plain NSWindow in this case) with an embedded TableView. Next I bind the value of the columns to amount and name which are stored within my array (called theArray, located in Global).

Here you see the window:
NSWindow.jpg
window with tableview
NSWindow.jpg (21.03 KiB) Viewed 1062 times


The binding for amount is shown here:
tableBinding.jpg
column binding via kvc
tableBinding.jpg (56.86 KiB) Viewed 1062 times


This works like a charm as long as the array is embedded in the global object. I tried to move the array to a place where it belongs (at least in my view) and located it inside my ukWindow class. This class isn't even listed as bind source, the binding inspector presents only instantiated objects for this. So I wanted to stay with the definition in Global and access this information from within the ukWindows instance.
This is where my question originated - is there a better way to bind to the array or even leave it within ukWindow?

Kind regards
Udo
Attachments
doodle.zip
the project with lots of alerts
(275.67 KiB) Downloaded 98 times
--------------
MacBook (2GHz, 4 GByte) - Lion (10.7.3)
started Objective Basic coding in April 2010 - still enjoy it ;-)
udo.killermann
 
Posts: 247
Joined: Thu Apr 08, 2010 6:46 am
Location: Hannover, Germany

Re: How to access properties of the Gloabl object

Postby berndnoetscher » Sun Jul 18, 2010 6:42 pm

Hi Udo,

changed your example, there is an iboutlet in global now and an object in ib created of type ukobject.
The iboutlet could be set to your window class (now it is a nswindow only) as well. Hope this helps.

Kind regards,
Bernd
Attachments
doodle.zip
(300.99 KiB) Downloaded 103 times
berndnoetscher
Site Admin
 
Posts: 280
Joined: Fri Feb 20, 2009 11:58 am

Re: How to access properties of the Gloabl object

Postby udo.killermann » Tue Jul 20, 2010 6:38 am

Hi Bernd,

thanks for this solution.

Kind regards
Udo
--------------
MacBook (2GHz, 4 GByte) - Lion (10.7.3)
started Objective Basic coding in April 2010 - still enjoy it ;-)
udo.killermann
 
Posts: 247
Joined: Thu Apr 08, 2010 6:46 am
Location: Hannover, Germany

Re: How to access properties of the Gloabl object

Postby berndnoetscher » Tue Jul 20, 2010 12:48 pm

Forgot to mention:
If you make the iboutlet in global public, it is accessable from everywhere.
berndnoetscher
Site Admin
 
Posts: 280
Joined: Fri Feb 20, 2009 11:58 am


Return to Objective-Basic (Xcode 3)

Who is online

Users browsing this forum: No registered users and 0 guests

cron