关于用file初始化NSString
来源:互联网 发布:知乎德国白啤酒 编辑:程序博客网 时间:2024/06/04 00:02
记下来吧,不然总是忘
转载自:http://my.oschina.net/ldgoooo/blog/77924
1、 从Resource 中 读取文件内容
1
NSBundle *bundel=[NSBundle mainBundle];
2
NSString *filePath=[bundel pathForResource:@
"txtfile"
ofType:@
""
];
3
NSLog(@
"filePath:%@"
,filePath);
4
NSString *fileContent=[NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
5
NSLog(@
"fileContent:%@"
,fileContent);
2、读取图片
01
NSBundle *bundel=[NSBundle mainBundle];
02
NSString *imgPath=[bundel pathForResource:@
"home"
ofType:@
"png"
];
03
UIImage *image=[UIImage imageWithContentsOfFile:imgPath];
04
UIImageView *imageView =[[UIImageView alloc]initWithImage:image];
05
[self.view addSubview:imageView];
06
07
//简便方法
08
UIImageView *imageView2=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@
"list"
]];
09
//move position
10
imageView2.center=CGPointMake(40, 15);
11
[self.view addSubview:imageView2];
1
NSFileManager *fm=[NSFileManager defaultManager];
2
NSString *path=[[NSBundle mainBundle]bundlePath];
3
NSArray *info=[fm contentsOfDirectoryAtPath:path error:nil];
4
NSLog(@
"list:%@"
,info);
- 关于用file初始化NSString
- 关于NSString。
- 关于NSString
- NSString字符串初始化总结
- 使用文件内容初始化NSString
- iphone 关于NSString
- 关于NSString的练习题
- 关于NSString的练习题
- 关于NSString转NSDictionary
- 以 GBK 的格式初始化NSString
- iOS5 Library NSString - 创建与初始化strings
- IOS5 Library NSString - 从文件初始化字符串
- NSString对象的初始化和比较
- nsstring 初始化方法不一样,地址不一样
- 关于初始化
- 关于初始化
- 关于初始化
- 关于初始化
- win8 第一个 应用
- 设计模式
- jdbc的日期问题
- kobject之kobject_uevent.c文件分析
- 迁移学习( Transfer Learning )
- 关于用file初始化NSString
- 缓存小小总结
- lib\kobject.c文件分析
- 分布式计算的定义
- CF 242E XOR on Segment
- PHp学习之路二(数组练习)
- Matlab 图像处理相关函数命令大全
- 面向对象设计模式
- 一个女孩的就业之路(同济大学BBS上两年不沉的帖子)