NSURL 子串截取

NSURL *url = [NSURL URLWithString:@"http://reg.email.163.com/unireg/call.do?cmd=register.entrance&from=163navi&regPage=163"];

    NSLog(@"Scheme: %@", [url scheme]);

    NSLog(@"Host: %@", [url host]);

    NSLog(@"Port: %@", [url port]);

    NSLog(@"Path: %@", [url path]);

    NSLog(@"Relative path: %@", [url relativePath]);

    NSLog(@"Path components as array: %@", [url pathComponents]);

    NSLog(@"Parameter string: %@", [url parameterString]);

    NSLog(@"Query: %@", [url query]);

    NSLog(@"Fragment: %@", [url fragment]);

    NSLog(@"User: %@", [url user]);

    NSLog(@"Password: %@", [url password]);

打印结果:

-- ::27.929 NSURLtestDemo[:] Scheme: http
-- ::27.929 NSURLtestDemo[:] Host: reg.email..com
-- ::27.929 NSURLtestDemo[:] Port: (null)
-- ::27.929 NSURLtestDemo[:] Path: /unireg/call.do
-- ::27.929 NSURLtestDemo[:] Relative path: /unireg/call.do
-- ::27.930 NSURLtestDemo[:] Path components as array: (
"/",
unireg,
"call.do"
)
-- ::27.930 NSURLtestDemo[:] Parameter string: (null)
-- ::27.930 NSURLtestDemo[:] Query: cmd=register.entrance&from=163navi&regPage=
-- ::27.930 NSURLtestDemo[:] Fragment: (null)
-- ::27.930 NSURLtestDemo[:] User: (null)
-- ::27.930 NSURLtestDemo[:] Password: (null)

需要对URL部分子串进行比较,需要截取其中一些字段,这种方式比较直观。

上一篇:js面向对象学习笔记(一):创建空对象,理解this指向


下一篇:paper 1:图像特征提取