This is not a question about a pertinent problem. It\'s a question by which I try to deepen my understanding of Objective-C or more specific Cocoa Foundation.
When d
Generally for path related operations you should prefer NSURL
over NSString
because the path information can be stored more efficiently in NSURL
(according to the class reference for NSFileManager
). So I would recommend that for your APIs you use also NSURL
.
Also NSURL
has URLByAppendingPathComponent:
and URLByAppendingPathExtension:
so convenience is served as well :-)
NSUrl
knows how to handle virtually any king of urls — not just Web-adresses and splits it into easy accessible chunks:
Now you can easily asks the url-object for this chunks, while in a string there might be the need for excessive if rules or complicated regex's.