I work with NSURL from time to time and invariably need a chart to remind me what the class provides in the form of helpers. I tend to write something like the following to refresh my memory.
[snippet id=”27″]
Here’s a couple of handy charts to help you decide which property to use.
File URLs (nulls removed)
NSURL Property | File Value |
---|---|
- (NSString *)absoluteString | file:///Users/you/Library/Application%20Support/iPhone%20Simulator /7.0.3/Applications/GUID/Library/Content/MobileHIG.pdf |
- (NSURL *)absoluteURL | file:///Users/you/Library/Application%20Support/iPhone%20Simulator /7.0.3/Applications/GUID/Library/Content/MobileHIG.pdf |
- (const char *) fileSystemRepresentation | /Users/you/Library/Application Support/iPhone Simulator /7.0.3/Applications/GUID/Library/Content/MobileHIG.pdf |
- (NSString *)lastPathComponent | MobileHIG.pdf |
- (NSString *)path | /Users/you/Library/Application Support/iPhone Simulator /7.0.3/Applications/GUID/Library/Content/MobileHIG.pdf |
- (NSArray *)pathComponents | ( "/", Users, you, Library, "Application Support", "iPhone Simulator", "7.0.3", Applications, GUID, Library, Content, "MobileHIG.pdf" ) |
- (NSString *)pathExtension | |
- (NSString *)relativePath | /Users/you/Library/Application Support/iPhone Simulator /7.0.3/Applications/GUID/Library/Content/MobileHIG.pdf |
- (NSString *)relativeString | file:///Users/you/Library/Application%20Support/iPhone%20Simulator /7.0.3/Applications/GUID/Library/Content/MobileHIG.pdf |
- (NSString *)resourceSpecifier | /Users/you/Library/Application%20Support/iPhone%20Simulator /7.0.3/Applications/GUID/Library/Content/MobileHIG.pdf |
- (NSString *)scheme | file |
- (NSURL *)standardizedURL | file:///Users/you/Library/Application%20Support/iPhone%20Simulator /7.0.3/Applications/GUID/Library/Content/MobileHIG.pdf |
Internet URLs (nulls removed)
NSURL Property | Internet Value |
---|---|
- (NSString *)absoluteString | http://blog.canispater.com:80/2013/11/nsurl-reference-chart/?pg=1&other=value |
- (NSURL *)absoluteURL | http://blog.canispater.com:80/2013/11/nsurl-reference-chart/?pg=1&other=value |
- (NSString *)host | blog.canispater.com |
- (NSString *)lastPathComponent | nsurl-reference-chart |
- (NSString *)path | /2013/11/nsurl-reference-chart |
- (NSArray *)pathComponents | ( "/", 2013, 11, "nsurl-reference-chart" ) |
- (NSNumber *)port | 80 |
- (NSString *)query | pg=1&other=value |
- (NSString *)relativePath | /2013/11/nsurl-reference-chart |
- (NSString *)relativeString | http://blog.canispater.com:80/2013/11/nsurl-reference-chart/?pg=1&other=value |
- (NSString *)resourceSpecifier | //blog.canispater.com:80/2013/11/nsurl-reference-chart/?pg=1&other=value |
- (NSString *)scheme | http |
- (NSURL *)standardizedURL | http://blog.canispater.com:80/2013/11/nsurl-reference-chart/?pg=1&other=value |
Helpful? Anyone? Anyone?