解析NSURL路径和查询(iphoneOS) [英] Parse NSURL path and query (iphoneOS)
问题描述
有没有任何标准对象或函数来解析NSURL的组件?显然,我可以写一个,但为什么要重新发明车轮?
[NSURL path]
code> NSString like argX = x& argY = y& argZ = z
是一个用 {@argX=> @x,@argY=>对于路径,它返回一个字符串,例如/ partA /,@y,@argZ= @z}
< partB / partC,我宁愿得到一个结构
{[0] => @partA,[1] => @partB,[2] => @partC}
我意识到这是一个非常具体的问题,但它似乎很多人想要的东西...
编辑 - 这是iphoneOS的!显然NSURL在Mac OS上有不同的功能
您可能想看看 pathComponents
它返回一个URL的组件数组。获取更多信息此处。
Are there any standard objects or functions to parse an NSURL's components? Clearly I could write one, but why re-invent the wheel?
[NSURL path]
will return an NSString
like "argX=x&argY=y&argZ=z"
What I would rather get back is a dictionary populated with {@"argX" => @"x", @"argY" => @"y", @"argZ" = @"z"}
For the path, which returns a string like "/partA/partB/partC", I would rather get an array with the structure {[0] => @"partA", [1] => @"partB", [2] => @"partC"}
I realize this is a pretty specific ask, but it seems like something a lot of people would want...
EDIT - This is for iphoneOS! Apparently NSURL has different functions on Mac OS
You might want to look at pathComponents
which returns an array of the components of the URL. Get more information here.
这篇关于解析NSURL路径和查询(iphoneOS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!