Ask a Question related to Mac Programming, Design and Development.
-
Toan #1
How can I access NSDocument?
I have a window that is up all the time from the main nib when the
application is launched. This window will process the data and
depending which document is active, I want to update the document from
the data in this window. I am having problem trying to get it to
work. I can easily access the main window from the document by
setting the delegate to the main window and call [NSApp delegate], but
I can't to it the other way around. For example, if I have a
NSTextField in my NSDocument. How do I update that data with the data
from the main window?
Toan Guest
-
Web Service + Anon Access, but getting 401 Access Denied Error
I have a simple webservice that just returns a string. The security for this is set to windows authentication in IIS (XP Professional) and anonymous... -
Access 2002 PDFWriter VBA Code w/WinXP does not work like Access 2000
I am trying to print an Access 2002 report (Windows XP OS) as a PDF. I had success with Access 2000 in a Windows 2000 environment, but as soon as I... -
Access Violation when using Visual Interdev to access Oracle
I am running Windows 200 Pro, IIS 5.0 and trying to connect to an Oracle 8.1 database. Prior to applying a security patch to W2k, the ASP... -
one NSDocument, multiple windows; no focus change
I've poked around a bit on getting multiple windows working under the NSDocument architecture, and have chosen the multiple NSWindowControllers... -
Getting NSDocument to load a file into current window
Hi!, I am new to Cocoa, and was hopeing someone could help me with a little problem I was having. I am writing a simple hex editor, and would like... -
matt neuburg #2
Re: How can I access NSDocument?
Toan <toan@asianboxoffice.com> wrote:
If you are using the document framework (that is, you started with a> I have a window that is up all the time from the main nib when the
> application is launched. This window will process the data and
> depending which document is active, I want to update the document from
> the data in this window. I am having problem trying to get it to
> work. I can easily access the main window from the document by
> setting the delegate to the main window and call [NSApp delegate], but
> I can't to it the other way around. For example, if I have a
> NSTextField in my NSDocument. How do I update that data with the data
> from the main window?
Document-Based Cocoa app project), then from an interface item you can
get its window and from a window you can get its windowController and
from a windowController you can get the document. For further reading:
...TasksAndConcepts/ProgrammingTopics/Documents/index.html
m.
--
matt neuburg, phd = [email]matt@tidbits.com[/email], [url]http://www.tidbits.com/matt/[/url]
Read TidBITS! It's free and smart. [url]http://www.tidbits.com[/url]
matt neuburg Guest
-
Toan #3
Re: How can I access NSDocument?
On Wed, 17 Sep 2003 22:03:39 GMT, [email]matt@tidbits.com[/email] (matt neuburg)
wrote:
Thanks for the quick response. So, would this be the correct way to>Toan <toan@asianboxoffice.com> wrote:
>>>> I have a window that is up all the time from the main nib when the
>> application is launched. This window will process the data and
>> depending which document is active, I want to update the document from
>> the data in this window. I am having problem trying to get it to
>> work. I can easily access the main window from the document by
>> setting the delegate to the main window and call [NSApp delegate], but
>> I can't to it the other way around. For example, if I have a
>> NSTextField in my NSDocument. How do I update that data with the data
>> from the main window?
>If you are using the document framework (that is, you started with a
>Document-Based Cocoa app project), then from an interface item you can
>get its window and from a window you can get its windowController and
>from a windowController you can get the document. For further reading:
>
> ...TasksAndConcepts/ProgrammingTopics/Documents/index.html
>
>m.
>
>
>--
>matt neuburg, phd = [email]matt@tidbits.com[/email], [url]http://www.tidbits.com/matt/[/url]
>Read TidBITS! It's free and smart. [url]http://www.tidbits.com[/url]
do it?
- (MyDocument *)getDocument
{
MyDocument *currentDoc;
NSArray *windows = [NSApp windows];
unsigned count = [windows count];
while (count--)
{
NSWindow *window = [windows objectAtIndex:count];
if (window)
{
MyDocument *currentDoc = [[window windowController]
document];
}
}
return currentDoc;
}
Toan Guest
-
matt neuburg #4
Re: How can I access NSDocument?
Toan <toan@asianboxoffice.com> wrote:
Sorry, it isn't obvious to me what problem that code is trying to solve.>So, would this be the correct way to
> do it?
>
> - (MyDocument *)getDocument
> {
> MyDocument *currentDoc;
> NSArray *windows = [NSApp windows];
>
> unsigned count = [windows count];
> while (count--)
> {
> NSWindow *window = [windows objectAtIndex:count];
> if (window)
> {
> MyDocument *currentDoc = [[window windowController]
> document];
> }
> }
>
> return currentDoc;
> }
m.
--
matt neuburg, phd = [email]matt@tidbits.com[/email], [url]http://www.tidbits.com/matt/[/url]
Read TidBITS! It's free and smart. [url]http://www.tidbits.com[/url]
matt neuburg Guest
-
Toan #5
Re: How can I access NSDocument?
On Wed, 17 Sep 2003 23:01:51 GMT, [email]matt@tidbits.com[/email] (matt neuburg)
wrote:
I'm trying to access the document from a different file. What I am>Toan <toan@asianboxoffice.com> wrote:
>>>>So, would this be the correct way to
>> do it?
>>
>> - (MyDocument *)getDocument
>> {
>> MyDocument *currentDoc;
>> NSArray *windows = [NSApp windows];
>>
>> unsigned count = [windows count];
>> while (count--)
>> {
>> NSWindow *window = [windows objectAtIndex:count];
>> if (window)
>> {
>> MyDocument *currentDoc = [[window windowController]
>> document];
>> }
>> }
>>
>> return currentDoc;
>> }
>Sorry, it isn't obvious to me what problem that code is trying to solve.
>m.
>
>--
>matt neuburg, phd = [email]matt@tidbits.com[/email], [url]http://www.tidbits.com/matt/[/url]
>Read TidBITS! It's free and smart. [url]http://www.tidbits.com[/url]
trying to do is to create a function that will allow me to get a
handle to the document. So, I was hoping that I can simply do the
following with that.
MyDocument *doc = [self getDocument];
[doc [setTextData str]];
setTextData would be a function define inside the document.
Toan Guest
-
matt neuburg #6
Re: How can I access NSDocument?
Toan <toan@asianboxoffice.com> wrote:
I'm sorry, the words "from a different file" don't convey anything to> I'm trying to access the document from a different file
me. Your desire is to say [self getDocument] but I don't understand who
"self" is or how he can fail to know what the document is. Who is self
and what document is he trying to obtain? m.
--
matt neuburg, phd = [email]matt@tidbits.com[/email], [url]http://www.tidbits.com/matt/[/url]
Read TidBITS! It's free and smart. [url]http://www.tidbits.com[/url]
matt neuburg Guest
-
Toan #7
Re: How can I access NSDocument?
On Thu, 18 Sep 2003 00:10:55 GMT, [email]matt@tidbits.com[/email] (matt neuburg)
wrote:
Since I'm used to program in C, maybe I might confuse myself. Here's>Toan <toan@asianboxoffice.com> wrote:
>>>> I'm trying to access the document from a different file
>I'm sorry, the words "from a different file" don't convey anything to
>me. Your desire is to say [self getDocument] but I don't understand who
>"self" is or how he can fail to know what the document is. Who is self
>and what document is he trying to obtain? m.
>
>
>--
>matt neuburg, phd = [email]matt@tidbits.com[/email], [url]http://www.tidbits.com/matt/[/url]
>Read TidBITS! It's free and smart. [url]http://www.tidbits.com[/url]
how it is.
I have a file maincontroller.m and MyMainController is connected to
the window in the main.nib
@interface MyMainController : NSObject
{
}
- (MyDocument *)getDocument
@end
So, if I was calling the function within the maincontroller.m, that is
MyMainController, don't I have to do a [self getDocument] ?
So, what it's trying to access is the MyDocument's records or
tableView that is define inside the document.nib
@interface MyDocument : NSDocument
{
NSMutableArray *records;
IBOutlet id tableView;
}
@end
Toan Guest
-
Paul Mitchum #8
Re: How can I access NSDocument?
Toan <toan@asianboxoffice.com> wrote:
[..]It probably won't solve your problem, but if you look at the> I'm trying to access the document from a different file. What I am trying
> to do is to create a function that will allow me to get a handle to the
> document. So, I was hoping that I can simply do the following with that.
>
> MyDocument *doc = [self getDocument];
> [doc [setTextData str]];
>
> setTextData would be a function define inside the document.
documentation for NSDocumentController's -documents method, things might
become more clear. Or more confused. :-)
You can get an array of all documents this way:
NSArray *allTheDocuments = [[NSDocumentController
sharedDocumentController] documents];
Then you'll be able to search and sort through the documents however you
want.
Paul Mitchum Guest
-
Per Bull Holmen #9
Re: How can I access NSDocument?
Toan <toan@asianboxoffice.com> wrote:
How about using NSDocumentController's - (id) currentDocument ?> So, if I was calling the function within the maincontroller.m, that is
> MyMainController, don't I have to do a [self getDocument] ?
>
> So, what it's trying to access is the MyDocument's records or
> tableView that is define inside the document.nib
Per
Per Bull Holmen Guest
-
Per Bull Holmen #10
Re: How can I access NSDocument?
Per Bull Holmen <pbh_news@yahoo.com> wrote:
By the way, this would be the code:> Toan <toan@asianboxoffice.com> wrote:
>>> > So, if I was calling the function within the maincontroller.m, that is
> > MyMainController, don't I have to do a [self getDocument] ?
> >
> > So, what it's trying to access is the MyDocument's records or
> > tableView that is define inside the document.nib
> How about using NSDocumentController's - (id) currentDocument ?
id theDocument = [[NSDocumentController sharedDocumentController]
currentDocument];
I have never tried it, so I don't know if it works.
Per
Per Bull Holmen Guest
-
Toan #11
Re: How can I access NSDocument?
On Wed, 17 Sep 2003 18:30:17 -0700, [email]usenet@mile23.com[/email].r3m0v3 (Paul
Mitchum) wrote:
>Toan <toan@asianboxoffice.com> wrote:
>
>[..]>>> I'm trying to access the document from a different file. What I am trying
>> to do is to create a function that will allow me to get a handle to the
>> document. So, I was hoping that I can simply do the following with that.
>>
>> MyDocument *doc = [self getDocument];
>> [doc [setTextData str]];
>>
>> setTextData would be a function define inside the document.
>It probably won't solve your problem, but if you look at the
>documentation for NSDocumentController's -documents method, things might
>become more clear. Or more confused. :-)
>
>You can get an array of all documents this way:
>
>NSArray *allTheDocuments = [[NSDocumentController
>sharedDocumentController] documents];
>
>Then you'll be able to search and sort through the documents however you
>want.
Okay, I'll try these method. I was surprised that the function I
define in the message ealier also worked. Although I am not exactly
sure if it's getting the current active document or not.
Toan Guest
-
matt neuburg #12
Re: How can I access NSDocument?
Toan <toan@asianboxoffice.com> wrote:
You do not "define" an NSDocument inside a nib. (The nib is where you> what it's trying to access is the MyDocument's records or
> tableView that is define inside the document.nib
>
> @interface MyDocument : NSDocument
> {
> NSMutableArray *records;
> IBOutlet id tableView;
> }
draw the windows.) The framework will create an NSDocument each time one
is needed (either because the user said New or because the user said
Open). There can be many NSDocuments (because the user can open many
documents at a time). So I still do not know which one you want. If I
don't know which NSDocument you want, I can't tell you how to access it.
You should read the explanation of the document architecture I pointed
you to earlier. m.
--
matt neuburg, phd = [email]matt@tidbits.com[/email], [url]http://www.tidbits.com/matt/[/url]
Read TidBITS! It's free and smart. [url]http://www.tidbits.com[/url]
matt neuburg Guest
-
Toan #13
Re: How can I access NSDocument?
On Thu, 18 Sep 2003 04:20:50 +0200, [email]pbh_news@yahoo.com[/email] (Per Bull
Holmen) wrote:
I tried this method and it didn't work. theDocument became 0, the>Per Bull Holmen <pbh_news@yahoo.com> wrote:
>>>> Toan <toan@asianboxoffice.com> wrote:
>>>>>> > So, if I was calling the function within the maincontroller.m, that is
>> > MyMainController, don't I have to do a [self getDocument] ?
>> >
>> > So, what it's trying to access is the MyDocument's records or
>> > tableView that is define inside the document.nib
>> How about using NSDocumentController's - (id) currentDocument ?
>By the way, this would be the code:
>
>id theDocument = [[NSDocumentController sharedDocumentController]
>currentDocument];
>
>I have never tried it, so I don't know if it works.
>
>Per
function I define actually worked.
Toan Guest
-
Per Bull Holmen #14
Re: How can I access NSDocument?
Toan <toan@asianboxoffice.com> wrote:
My guess is that at the time you call the function, the main document is> On Thu, 18 Sep 2003 04:20:50 +0200, [email]pbh_news@yahoo.com[/email] (Per Bull
> Holmen) wrote:
>>> >Per Bull Holmen <pbh_news@yahoo.com> wrote:
> >> >> >> Toan <toan@asianboxoffice.com> wrote:
> >>
> >> > So, if I was calling the function within the maincontroller.m, that is
> >> > MyMainController, don't I have to do a [self getDocument] ?
> >> >
> >> > So, what it's trying to access is the MyDocument's records or
> >> > tableView that is define inside the document.nib
> >>
> >> How about using NSDocumentController's - (id) currentDocument ?
> >By the way, this would be the code:
> >
> >id theDocument = [[NSDocumentController sharedDocumentController]
> >currentDocument];
> >
> >I have never tried it, so I don't know if it works.
> >
> >Per
> I tried this method and it didn't work. theDocument became 0, the
> function I define actually worked.
not your main window, because the "shared" window is, and so
+currentDocument returns nil.
You must have a method wich always points to the current document and no
other document. My suggestion is you keep a static reference that always
points to the main document:
@implementation MainController
static id currentDocument = nil;
+(void)setCurrentDocument:(id)newDoc {
currentDocument = newDoc;
}
+(id)currentDocument {
return currentDocument;
}
+(void)documentGotClosed:(id)closeDoc {
if( closeDoc == currentDocument )
currentDocument = nil; // To avoid keeping references to
invalid objects
}
// insert the rest of your code here
Now you can always retrieve the current document this way:
[MainController currentDocument];
Set current document like this:
[MainController setCurrentDocument:theDoc];
In setCurrentDocument:, you should define the actions to update the
shared window, so it always keeps the "shared" window updated, no matter
if it's active or not etc...
Now what you have to do, is make sure the appropriate methods always get
called at the right time.... this requires a little investigation from
your part:
* You may use NSNotifications, to have MainController always get
notified when a new document is current.
* Override methods in either the documents window class (which must be
subclassed), or the document (if NSDocument has defined methods for a
document to become current).
This is by far the best approach, because (if implemented correctly) it
ALWAYS makes sure the maincontroller knows what document is active, and
it ensures immediate update of the shared window. Also, the method for
retrieving the shared window (via MainController) should be:
static id sharedWindow = nil;
+(void)setSharedWindow:(id)theWin {
sharedWindow = theWin;
}
+(id)sharedWindow {
return sharedWindow;
}
This is better than "weird" solutions like setting the NSApp's delegate
if it's not needed for other reasons. Sorry this requires you to read
and investigate a little if you're new to Objectve-C/Cocoa, but then
again you learn the right way to do things... :)
Per
Per Bull Holmen Guest
-
Toan #15
Re: How can I access NSDocument?
On Thu, 18 Sep 2003 03:05:27 GMT, [email]matt@tidbits.com[/email] (matt neuburg)
wrote:
The main controller will always try to access the active document.>Toan <toan@asianboxoffice.com> wrote:
>>>> what it's trying to access is the MyDocument's records or
>> tableView that is define inside the document.nib
>>
>> @interface MyDocument : NSDocument
>> {
>> NSMutableArray *records;
>> IBOutlet id tableView;
>> }
>You do not "define" an NSDocument inside a nib. (The nib is where you
>draw the windows.) The framework will create an NSDocument each time one
>is needed (either because the user said New or because the user said
>Open). There can be many NSDocuments (because the user can open many
>documents at a time). So I still do not know which one you want. If I
>don't know which NSDocument you want, I can't tell you how to access it.
>You should read the explanation of the document architecture I pointed
>you to earlier. m.
>
>
>--
>matt neuburg, phd = [email]matt@tidbits.com[/email], [url]http://www.tidbits.com/matt/[/url]
>Read TidBITS! It's free and smart. [url]http://www.tidbits.com[/url]
So, if there are 10 documents open, the main controller will access
the last selected one (could be the first opened one).
Toan Guest
-
Toan #16
Re: How can I access NSDocument?
On Thu, 18 Sep 2003 12:16:02 +0200, [email]pbh_news@yahoo.com[/email] (Per Bull
Holmen) wrote:
I thought about doing it that way because that's how I used to do it>Toan <toan@asianboxoffice.com> wrote:
>>>> On Thu, 18 Sep 2003 04:20:50 +0200, [email]pbh_news@yahoo.com[/email] (Per Bull
>> Holmen) wrote:
>>>>>> >Per Bull Holmen <pbh_news@yahoo.com> wrote:
>> >
>> >> Toan <toan@asianboxoffice.com> wrote:
>> >>
>> >> > So, if I was calling the function within the maincontroller.m, that is
>> >> > MyMainController, don't I have to do a [self getDocument] ?
>> >> >
>> >> > So, what it's trying to access is the MyDocument's records or
>> >> > tableView that is define inside the document.nib
>> >>
>> >> How about using NSDocumentController's - (id) currentDocument ?
>> >
>> >By the way, this would be the code:
>> >
>> >id theDocument = [[NSDocumentController sharedDocumentController]
>> >currentDocument];
>> >
>> >I have never tried it, so I don't know if it works.
>> >
>> >Per
>> I tried this method and it didn't work. theDocument became 0, the
>> function I define actually worked.
>My guess is that at the time you call the function, the main document is
>not your main window, because the "shared" window is, and so
>+currentDocument returns nil.
>
>You must have a method wich always points to the current document and no
>other document. My suggestion is you keep a static reference that always
>points to the main document:
>
>@implementation MainController
>
> static id currentDocument = nil;
>
> +(void)setCurrentDocument:(id)newDoc {
>
> currentDocument = newDoc;
>
> }
>
> +(id)currentDocument {
>
> return currentDocument;
>
> }
>
> +(void)documentGotClosed:(id)closeDoc {
>
> if( closeDoc == currentDocument )
> currentDocument = nil; // To avoid keeping references to
>invalid objects
>
> }
>
> // insert the rest of your code here
>
>Now you can always retrieve the current document this way:
>[MainController currentDocument];
>
>Set current document like this:
>[MainController setCurrentDocument:theDoc];
>
>In setCurrentDocument:, you should define the actions to update the
>shared window, so it always keeps the "shared" window updated, no matter
>if it's active or not etc...
>
>Now what you have to do, is make sure the appropriate methods always get
>called at the right time.... this requires a little investigation from
>your part:
>
>* You may use NSNotifications, to have MainController always get
>notified when a new document is current.
>* Override methods in either the documents window class (which must be
>subclassed), or the document (if NSDocument has defined methods for a
>document to become current).
>
>This is by far the best approach, because (if implemented correctly) it
>ALWAYS makes sure the maincontroller knows what document is active, and
>it ensures immediate update of the shared window. Also, the method for
>retrieving the shared window (via MainController) should be:
>
> static id sharedWindow = nil;
>
> +(void)setSharedWindow:(id)theWin {
>
> sharedWindow = theWin;
>
> }
>
> +(id)sharedWindow {
>
> return sharedWindow;
>
> }
>
>This is better than "weird" solutions like setting the NSApp's delegate
>if it's not needed for other reasons. Sorry this requires you to read
>and investigate a little if you're new to Objectve-C/Cocoa, but then
>again you learn the right way to do things... :)
>
>Per
on the Windows side. Except that I also need to call [MainController
setCurrentDocument:this]; whenever a document gets focus. What I
really want to do is to make the maincontroller like a tool window
that never gets focus. You can click on the action you want and it
will always perform on your current active document. So, of course
the best would be able to just cycle through all the windows, find the
top most one or the active one. Check to see if it's a document type.
Also, can you tell me what's the difference between the + and -
infront of the function?
Toan Guest
-
Peter Ilberg #17
Re: How can I access NSDocument?
[email]toan@asianboxoffice.com[/email] (Toan) writes:In that case you probably want to use a panel rather than a> I thought about doing it that way because that's how I used to do it
> on the Windows side. Except that I also need to call [MainController
> setCurrentDocument:this]; whenever a document gets focus. What I
> really want to do is to make the maincontroller like a tool window
> that never gets focus. You can click on the action you want and it
> will always perform on your current active document. So, of course
> the best would be able to just cycle through all the windows, find the
> top most one or the active one. Check to see if it's a document type.
window. I haven't done this myself, but the documentation on
Apple's site suggests that.
[url]http://developer.apple.com/documentation/Cocoa/Conceptual/WinPanel/index.html#//apple_ref/doc/uid/10000031i[/url]
Btw, CocoaBrowser is a really great tool for looking at the
documentation.
[url]http://homepage2.nifty.com/hoshi-takanori/cocoa-browser/[/url]
The + means it's a class method, - means it's an instance> Also, can you tell me what's the difference between the + and -
> infront of the function?
method. For example, alloc is a class method because you invoke it
on the class object to create a new instance of that class. Init
is an instance method because you invoke it on a particular
object.
id a = [NSArray array]; // class method
[a objectAtIndex: i]; // instance method
Check out Apple's Objective-C documentation for more.
Also, cycling though array elements based on index works, but I
believe the preferred way of doing this is to use NSEnumerator.
[url]http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSArray.html#//apple_ref/doc/uid/20000137/BABCDDIC[/url]
Hope this helps,
Peter
-- Peter Ilberg <peter.ilberg@ni.com>
Peter Ilberg Guest
-
Eric Pepke #18
Re: How can I access NSDocument?
[email]toan@asianboxoffice.com[/email] (Toan) wrote in message news:<3f68d2ea.452947824@news.dslindiana.com>...
I'm not sure exactly what you're asking. I'm not sure what exactly> I have a window that is up all the time from the main nib when the
> application is launched. This window will process the data and
> depending which document is active, I want to update the document from
> the data in this window. I am having problem trying to get it to
> work. I can easily access the main window from the document by
> setting the delegate to the main window and call [NSApp delegate], but
> I can't to it the other way around. For example, if I have a
> NSTextField in my NSDocument. How do I update that data with the data
> from the main window?
you're
calling the main window, because that term has another meaning in
Cocoa.
Is this, like, the tools window in Interface Builder? In that case,
this is
an NSPanel, which should never be the main window. The main window
is, roughly, the topmost regular window, usually a document window.
If this is what you're doing, it's simple. Give your NSPanel a custom
subclass of NSWindowController. When this needs to find out what
the main (i.e. topmost document window), it can do [[NSApplication
sharedApplication] mainWindow]; to find out what the document
window is. It can also be notified when the main window changes,
so that it can stay up-to-date, like this:
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(loadObserver:)
name:(NSString *)NSWindowDidBecomeMainNotification
object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(loadObserver:)
name:(NSString *)NSWindowDidResignMainNotification
object:nil];
This is a quote from some of my code, where loadObserver (you'd maybe
want to call it loadDocument) is declared like this:
- (void)loadObserver:(id)notification;
This method is responsible for getting information from the document.
Your subclassed controller will keep track of the main (document)
window.
As the user moves controls or it computes or whatever, it can use this
information to stuff everything back into the main (document) window.
If this *isn't* what you're doing, such as if you're trying to make
this
common window a regular window rather than a panel, I suggest
rethinking the design, because that window can become main as
well, and it may confuse the user, who will be unable to tell at a
glance which is the main window.
Eric Pepke Guest
-
Toan #19
Re: How can I access NSDocument?
On 18 Sep 2003 10:38:39 -0500, Peter Ilberg <peter.ilberg@ni.com>
wrote:
Hmmm, I should think about doing that. So, can I put a whole>In that case you probably want to use a panel rather than a
>window. I haven't done this myself, but the documentation on
>Apple's site suggests that.
>
quicktime video control inside a panel? Currently, my main window is
where all the video process the data.
I see. For a while, I thought that was just a way Objective C define>[url]http://developer.apple.com/documentation/Cocoa/Conceptual/WinPanel/index.html#//apple_ref/doc/uid/10000031i[/url]
>
>Btw, CocoaBrowser is a really great tool for looking at the
>documentation.
>
>[url]http://homepage2.nifty.com/hoshi-takanori/cocoa-browser/[/url]
>>>> Also, can you tell me what's the difference between the + and -
>> infront of the function?
>The + means it's a class method, - means it's an instance
>method. For example, alloc is a class method because you invoke it
>on the class object to create a new instance of that class. Init
>is an instance method because you invoke it on a particular
>object.
it's function.>
> id a = [NSArray array]; // class method
> [a objectAtIndex: i]; // instance method
>
>Check out Apple's Objective-C documentation for more.
>
>Also, cycling though array elements based on index works, but I
>believe the preferred way of doing this is to use NSEnumerator.
>
>[url]http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSArray.html#//apple_ref/doc/uid/20000137/BABCDDIC[/url]
>
>Hope this helps,
>
>Peter
>
>-- Peter Ilberg <peter.ilberg@ni.com>Toan Guest
-
Peter Ilberg #20
Re: How can I access NSDocument?
[email]toan@asianboxoffice.com[/email] (Toan) writes:Why not simply create a new document window when the user clicks> Hmmm, maybe I need to redesign the application. What I am trying to
> do in this common window is to run quicktime connected to a capture
> card. Since that is done at the start of the application, the window
> will never close until you exit the application. Now, depending on
> which document you have open, clicking on the grab button in the
> common window will automatically save an image and display it to the
> appropriate document (that is the active one).
grab and display the image in there? Otherwise the user has to
create a new empty window first and then grab the image. That
seems wrong.
Then, if you intend to allow the user to manipulate the captured
image, you can implement a tools palette in a separate NSPanel.
(separate from your quicktime window)
-- Peter Ilberg <peter.ilberg@ni.com>
Peter Ilberg Guest



Reply With Quote

