Objective-C类,NSUrl介绍和使用
来源:互联网 发布:吴昕淘宝店omg关了吗 编辑:程序博客网 时间:2024/04/30 22:32
1,NSUrl的初始化方法
NSURL *url = [NSURL URLWithString:@"http://www.baidu.com?key=4&content=1111"];
2,NSUrl的基本操作
NSURL *url = [NSURL URLWithString:@"http://www.baidu.com?key=4&content=1111"]; 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]);
结果:
3,解决NSURL初始化失败的问题
将传进来的NSString 进行 UTF8 转码。
NSString *strLocalHtml = @"file:///Users/amarishuyi/Desktop/My IPhone Life/WebDeveloper/WebPlug-in/ExtEditor/DataPage/KMQT/Ext-HTMLEditor.html"; strLocalHtml = [NSString stringWithFormat:@"%@?Value=%@",strLocalHtml,self.txtUrl.text]; strLocalHtml= [strLocalHtml stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSURL * url=[NSURL URLWithString:strLocalHtml];
4:根据文件名称和文件后缀获取程序包内容文件的路径
NSURL *urlKindEditor = [[NSBundlemainBundle] URLForResource:@"simple"withExtension:@"html"subdirectory:@"KindEditor/examples"];
URLForResource:文件名称
withExtension:文件后缀
subdirectory:在程序包中的哪个子目录中寻找.
如果没有找到将会返回nil。
0 0
- Objective-C类,NSUrl介绍和使用
- Objective-C类,NSBundle介绍和使用
- objective-C之NSURL
- Objective-C开发之----NSURL
- Objective-C 根据NSURL读取网络资源
- Objective-C 的类和对象的创建和使用
- 简单使用NSURLConnection、NSURLRequest和NSURL
- 混合使用Objective-C,C++和Objective-C++(转载)
- OutMan——Objective-C中的ARC介绍和block的使用
- 黑马程序员----Objective-C学习笔记之点语法的介绍和使用
- Objective-c NSFileManager类和NSFileHandle类的使用
- Objective -C 的介绍
- Objective C简单介绍
- Objective-C属性介绍
- Objective-C属性介绍
- Objective-C属性介绍
- Objective-C属性介绍
- Objective-C objc_class 介绍
- 使用iptables配置linux服务器请求转发
- Github上README.md介绍
- hdu5384-多校 ac自动机
- CSU 1672 Pool in minecraft
- 557 - Burger(递推)
- Objective-C类,NSUrl介绍和使用
- 小胖说事38----tableview:ios7 分割线短 15 像素(废弃) ios8方法如何将分割线还原
- android:ellipsize属性的含义
- Qt信号与槽
- STM32中assert_param的使用
- [leetcode 220]Contains Duplicate III
- crontab 定时完成某任务
- web 前端学习笔记(1)
- ZigZag字符长转换