Object-c 文件系统相关类
来源:互联网 发布:3d动漫设计软件 编辑:程序博客网 时间:2024/05/16 06:30
NSBundle类用来读取应用程序包内的相关资源
示例:
NSString *txtFilePath = [[NSBundle mainBundle] pathForResource:@"instructions" ofType:@"txt"];
mainBoundle代表当前的应用程序资源包,pathForResource:ofType返回指定文件的路径,可以通过该路径读取相应的资源
NSString *instructions = [NSString stringWithContentsOfFile:txtFilePath encoding:NSUTF8StringEncoding error:NULL];
如果要获得一个文件夹里所以图片的路径可以使用如下方法:
NSArray *birds = [[NSBundle mainBundle] pathsForResourcesOfType:@"jpg" inDirectory:@"birdImages"];
NSURL的使用方法:
#import <Foundation/Foundation.h>int main(int argc, const char * argv[]){ @autoreleasepool { // insert code here... NSLog(@"Hello, World!"); NSURL *myURL = [NSURL URLWithString:@"http://www.baidu.com"]; NSString *myHomePage = [NSString stringWithContentsOfURL:myURL encoding:NSASCIIStringEncoding error:NULL]; NSLog(@"%@",myHomePage); } return 0;}如果该url地址存储了一个dictionary,可以使用dictionaryWithContentsOfURL:
如果该url地址存储了一个array,可以使用arrayWithContentsOfURL:
也可以使用dataWithContentsOfURL:
- Object-c 文件系统相关类
- Object-C 属性相关
- Object-C相关知识
- Object-C 相关知识
- Object-c 学习相关
- Object-C 相关东西
- 【Object-C】Object-C 的包装类
- object类中相关方法
- 2.9 Object类,包相关
- 文件系统相关
- Object-C类实例
- Object-C 类定义
- Object-C-NSArray类
- Object-C-NSDictionary类
- (object-c)枚举类
- object-c常用类
- Object-C学习--类
- 【Object C】 类
- 警句
- akka模型用sender可以动态指定
- Linux内核和用户空间通信的方法— 使用netlink
- 网络游戏demo开发实例:多人在线RPG游戏(MMO RPG)demo的开发记录(第8篇)
- ibatIS 参数类型设置,内联参数映射与外联参数映射
- Object-c 文件系统相关类
- linux的clone()函数
- char[]与char*的区别
- Linux内核和用户空间通信的方法— 使用netlink (续)
- Hook IDirect3DDevice9::Present
- TESTNG--Introduction 笔记2012-9-5
- HDOJ 1234 开门人和关门人(水题)
- 安装hadoop和gluster
- hdu 1897 SnowWolf's Wine Shop multiset 运用 STL