Global vars vs IB
Global vars vs IB
- Subject: Global vars vs IB
- From: Michael Carter <email@hidden>
- Date: Tue, 2 Mar 2004 05:01:01 -0800
Hello all.
I am new to Obj-C and XCode, and am trying to work out a scope issue.
I am building an app in XCode following the Model-Controller-View
paradigm. However, I am stuck on how to access a class instance I
defined in the controller class from my view class. In this app, a
barcode is generated and it's results displayed in an NSView. What I'm
trying to do is implement the NSDraggingSource protocol to allow a user
to drag the image of the created barcode to the Finder in order to save
it as an EPS file.
In the view I am using
dragImage:at:offset:event:pasteboard:source:slideBack: in order to
allow the drag, however, I need to get to the instance of the barcode
class to obtain the EPS source I must create my NSPasteboard with. This
instance is declared in the controller object.
[MyBarcode] -> [Controller] -> [MyView]
The way I see it so far, I can either make the barcode instance global
in scope somehow, pass the instance around willy-nilly or perhaps
instantiate the barcode class in IB and make an outlet where the view
can send a message similar to [barcode sendMeTheEPSCode]. Which would
be the best approach? Would an object calling this message get the same
object that the controller has instantiated?
Thanks in advance.
______________
Mike Carter
Pilot/Programmer
Aviate.Org
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.