Tuesday, December 17, 2013

Add an empty file, why not open by nsfilehangle ah, seeking guidance

- (Void) viewDidLoad
{
/ / NSMutableData * data;
NSFileManager * fm = [NSFileManager defaultManager];
NSString * path = [fm currentDirectoryPath];
/ / NSArray * dirarray;
infile_ = [NSFileHandle fileHandleForReadingAtPath: @ "/ jia"];
NSMutableString * string = [[NSMutableString alloc] init];
if (infile_! = nil) {
NSMutableArray * temparray = [[NSMutableArray alloc] init];
while ([infile_ offsetInFile] == [infile_ seekToEndOfFile])
{
NSData * tempdata = [infile_ readDataOfLength: 1];
string = (NSMutableString *) tempdata;
/ / [Data appendData: tempdata];
[Temparray addObject: string];
/ / Data = nil;
}
self.array = temparray;
}
else
{
/ / Dirarray = [fm directoryContentsAtPath: path];
text_.text = path;
}
[Super viewDidLoad];
}

Reply:
Path seems unlikely right ah, lz commissioning proposal to see if the path is correct.
Also, I find some relevant code:

NSString * path = [[NSBundle mainBundle] pathForResource: @ "webViewContent" ofType: @ "html"];
NSFileHandle * readHandle = [NSFileHandle fileHandleForReadingAtPath: path];
Reply:
I also think it is wrong path, but I do not know how to change it, do not know is how the path, measured under the home directory is /,
Reply:
File is opened, there is what I want to read one by one, and then stored in an array, do not know how to do, find examples

No comments:

Post a Comment