I just looked at what’s in my pathControl - the objectValue and URL are both 
the same, the initial 
file://localhost/Applications/<file:///localhost/Applications/> that you see in 
the nib. Makes sense - if you’re letting the PathControl make the components it 
builds them from the URL, but it doesn’t change the URL if you change the 
cells. That makes sense even for the standard one; for local files the title is 
going to be displayNameAtPath, not the URL segment, so it’s not even reversible 
there.

I make my own cells and set the title & image from what’s in my tree, it 
doesn’t try to replace them later. It probably only changes them when you 
setURL:

On Jun 1, 2015, at 8:25 PM, Quincey Morris 
<[email protected]<mailto:[email protected]>>
 wrote:

On Jun 1, 2015, at 17:56 , Graham Cox 
<[email protected]<mailto:[email protected]>> wrote:

4. The control represents a “path” that isn’t anything like a URL, such as a 
tree node

My point was that NSPathControl apparently constructs URLs out of the path 
components, regardless of what you’re really representing, and regardless of 
how you originally configured them. From NSPathControl.h:

/* Gets and sets the path value displayed. When setting, an array of 
NSPathControlItems will automatically be set based on the path in the 'url'. If 
the 'url' is a file URL (returns YES from isFileURL), the images will 
automatically be filled up with file icons, if the path exists.  The URL value 
itself is stored in the objectValue of the control.
 */
@property (copy) NSURL *URL;

Note where it says “is stored in the objectValue”. Similarly, in 
NSPathControlItem.h:

/* A url for the partial path from the beginning up to this particular item.
 */
@property (readonly) NSURL *URL;

None of this is a problem, since you should be able to construct a URL out of 
any array of component strings, with proper escaping. So regardless of your 
intention, NSPathControl may attempt to classify this URL as one of #1-#3. Your 
case #4 still produces a URL that is one of those 3 cases.

I was really asking whether NSPathControl can mess up what you and Lee Ann are 
doing, if you give it an array of components whose titles happen to be 
[“Users”, “yourname”], for example. In that case, the URL 
file:///Users/yourname really exists — it’s your home directory — and I’m not 
sure that NSPathControl won’t display this is starting with your home directory 
icon, and dropping the first component. At least, that’s what I think I’ve seen 
it do with that URL. Presumably this will not be what you intended, if it 
happens.

But it’s not that important. If it seems to be working for you, I’m happy to 
hear it.


_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to