[Newbie] Getting path
[Newbie] Getting path
- Subject: [Newbie] Getting path
- From: kunikyo <email@hidden>
- Date: Mon, 14 Apr 2003 20:39:07 +0900
Hello all,
Now I am reading "Cocoa Programming" by Scott Anguish, et al.
and have a basic question about getting path
that I'm hoping people can answer.
On page 240, I have found following method.
- (NSString *)documentPath
/*" Returns the document's path or nil. "*/
{
return _myDocumentPath;
}
I could not understand the mechanism
of getting path using this method.
This method is called at the following part.
activeDocument = [self activeDocument];
if(nil != activeDocument && [activeDocument
respondsToSelector:@selector(documentPath)])
{
// Use active document's directory as initial directory
directory = [[activeDocument documentPath]
stringByDeletingLastPathComponent];
} else {
directory = @"";
}
At this part, active document is gotten in already open
documents and directory is gotten by the document's path.
activeDocument method is as follows and returns the last object
of the already open documents.
- (id)activeDocument
{
// The last object in _myOpenDocuments is assumed to be the active
document
return (0 < [_myOpenDocuments count]) ? [_myOpenDocuments lastObject]
: nil;
}
My question is that from
activeDocument = [self activeDocument]; point
to
[activeDocument documentPath] point
_myDocumentPath is not changed,
but at the point
return _myDocumentPath;
_myDocumentPath has already contains the
path of active document.
_myDocumentPath
is defined as
NSString *_myDocumentPath;
and used at
- (void)_mySetDocumentPath:(NSString *)aPath
and where I have a question and
- (void)dealloc
I think I have a simple missing link.
Thanks for the assistance!
Kunikyo
_______________________________________________
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.