Re: import Header??
Re: import Header??
- Subject: Re: import Header??
- From: Andrew Merenbach <email@hidden>
- Date: Fri, 25 Aug 2006 08:25:32 -0700
The shared instance idea would work, certainly, but I'm guessing that
MyDownload is an instance variable of MyDocument, or of something
connected with MyDocument.
Therefore, use a single accessor in MyDownload, as Alan suggested,
which (if you have an instance variable in MyDocument) you can access
with:
@implementation MyDocument
- (void)someMethod
{
NSArrayController *theArrayController = [myDownloadInstance
downloadArrayController];
[theArrayController doSomething];
}
@end
@implementation MyDownload
/* lifted from Alan's code */
- (NSArrayController*)downloadArrayController
{
return arrayController;
}
@end
If your MyDownload object is contained in *something else* that is
then contained by MyDocument, use what are called "cover methods."
In that case, use something like the following:
@implementation MyDocument
- (void)someMethod
{
NSArrayController *theArrayController =
[[myIntermediateObjectInstance theDownload] downloadArrayController];
[theArrayController doSomething];
}
@end
@implementation MyIntermediateObject
- (MyDownload *)theDownload
{
return myDownloadInstance;
}
@end
@implementation MyDownload
/* lifted from Alan's code */
- (NSArrayController*)downloadArrayController
{
return arrayController;
}
@end
Hope this helps! Someone else could probably phrase it a bit more
clearly. Apologies if it seems at all confusing.
Cheers,
Andrew
On Aug 25, 2006, at 7:39 AM, Alan Smith wrote:
Yes, this is fixable.
The error is because the ArrayController is not declared in
MyDocument. To access it from MyDocument put something like this in
MyDownload:
- (NSArrayController*)downloadArrayController
{
return arrayController;
}
You can name the method anything you like, also change the name of the
returned variable to the name of the IBOutlet.
This won't wok alone so add this too:
static MyDownload *sharedInstance = nil;
- (void)awakeFromNib
{
if (sharedInstance == nil)
sharedInstance = self;
}
- (MyDownload*)sharedInstance
{
return sharedInstance;
}
Now, to access it from MyDocument use some code like this:
id outlet = [[MyDownload sharedInstance] arrayController];
You then can do whatever you want with the outlet.
Enjoy, Alan
On 8/25/06, Bastiaan <email@hidden> wrote:
Dear Readers,
I imported "MyDocument.h" into "MyDownload.h", i was hoping this was
enough but now it gives me an error during a compile
'logoArrayController' undeclared (first use in this function)
LogoArrayController is named in MyDocument.h as an outlet, why does
it give me the error above and how can i solve it so that i can make
use of the ArrayController in MyDownload?
Hopefully somebody outthere can help me out!
Kind regards
Bastiaan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com
This email sent to email@hidden
--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"Don't waste your life doing things others have already done."
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40ucla.edu
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden