Re: NSOutlineView developer example
Re: NSOutlineView developer example
- Subject: Re: NSOutlineView developer example
- From: Marco Masser <email@hidden>
- Date: Thu, 4 Sep 2008 09:36:58 +0200
so far so good. But when I change the "initWithPath" to
"initWithPath:@"/Volumes/MyDisk/path/to/any/directory", as Ben said,
i want the same behaviour like with the "/" only, but a tree from my
path there. But this does not happen. Instead, i get a single row
with the last path component with NO triange on the side, so this is
kind of useless.
Does anyone know why this happens?
Erm... hi...
The problem is not the root path itself, but the -fullPath method:
- (NSString *)fullPath {
return result = parent ? [[parent fullPath]
stringByAppendingPathComponent:relativePath] : relativePath;
}
If the fullPath of the root item should be returned, this just returns
its relative path. This works because for "/", the full and the
relative path are the same. If your root item should be /Users, the
full path is "/Users", but the above method returns just "Users",
therefore rendering all subsequent child item's paths useless. To get
it working in a quick'n'dirty way, I tried the following (it works):
1) Add a new ivar called rootPath
2) In -initWithPath:parent: check whether the parten item passed is
nil. If so, set the path passed as the rootPath
3) Modify the -fullPath method to look like this:
- (NSString *)fullPath {
return result = parent ? [[parent fullPath]
stringByAppendingPathComponent:relativePath] : rootPath;
}
Marco
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden