-(void)redfile { FILE *fp=fopen([[self bundlePath:@"information.txt"]UTF8String], "r"); char word[100]; if (!fp) { return; } while(fgets(word, 100,fp)) { word[strlen(word)-1] = '\0'; NSLog(@"%s",word); } fclose(fp); } //读取同目录下文件路jin -(NSString *)bundlePath:(NSString *)fileName { return [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:fileName]; }
转载于:https://www.cnblogs.com/qingjoin/archive/2012/06/28/2567483.html