int main(int argc, constchar* argv[])
{
NSAutoreleasePool* pool= [[NSAutoreleasePool alloc] init];
//NSString* filename=@"~/LearningCocoa/filestrings/filestrings.m";
NSString *filename1=[[NSBundlemainBundle] pathForResource:@"textfile"ofType:@"txt"];//先把文件导入
filename= [filename stringByStandardizingPath];printf("%s\n", [filename UTF8String]);
NSString* source= [NSString stringWithContentsOfFile : filename];
printf("%s\n", [source UTF8String]);
[pool drain];
return0;
}
isgl3d读取文件
NSString *filename1=[[NSBundlemainBundle] pathForResource:@"textfile"ofType:@"txt"];
filename1 = [filename1 stringByStandardizingPath];
printf("%s\n", [filename1UTF8String]);
NSString * source = [NSStringstringWithContentsOfFile : filename1 encoding:NSUTF8StringEncoding error:nil];
int length = [source length];
NSLog(@"%@", source);
_vertexData = (unsignedchar *)malloc(sizeof(unsignedchar)*length);
_vertexData = (unsignedchar *)[source UTF8String];
NSLog(@"length : %d", length);