数据读写——NSFileHandle(3)
来源:未知 责任编辑:责任编辑 发表时间:2014-02-02 17:44 点击:次
p> fileManager = [NSFileManager defaultManager];
p>
p> if ([fileManager fileExistsAtPath:filePath]) {
p> NSLog(@"存在该文件");
p> NSFileHandle *fileHandle;
p> fileHandle = [NSFileHandle fileHandleForReadingAtPath:filePath];
p>
p> NSString *outputString = [[NSString alloc] initWithData:[fileHandle availableData] encoding:NSUTF8StringEncoding];
p> [fileHandle closeFile];
p>
p> self.informationView.text = outputString;
p> }
p>}
p>
p>- (IBAction)loadInformation:(id)sender {
p> NSString *docDir, *filePath;
p> NSFileManager *fileManager;
p>
p> docDir = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
p> filePath = [docDir stringByAppendingPathComponent:@"myInfoList.csv"];
p> fileManager = [NSFileManager defaultManager];
p>
p> if ([fileManager fileExistsAtPath:filePath]) {
p> NSLog(@"存在该文件");
p> NSFileHandle *fileHandle;
p> fileHandle = [NSFileHandle fileHandleForReadingAtPath:filePath];
p>
p> NSString *outputString = [[NSString alloc] initWithData:[fileHandle availableData] encoding:NSUTF8StringEncoding];
p> [fileHandle closeFile];
p>
p> self.informationView.text = outputString;
p> }
p>}
p>
p>实现其他方法
p>[cpp]
p>- (IBAction)tappedEndEditing:(id)sender {
p> [self.view endEditing:YES];
p>}
p>
p>- (IBAction)tapped:(id)sender {
p> self.informationView.text = @"";
p>}
p>
p>- (IBAction)tappedEndEditing:(id)sender {
p> [self.view endEditing:YES];
p>}
p>
p>- (IBAction)tapped:(id)sender {
p> self.informationView.text = @"";
p>}
p>一个隐藏键盘,一个手势操作。
p>
p>
相关新闻>>
- 发表评论
-
- 最新评论 更多>>