Sportica   Sportica

obj-c 读取文件 。

-(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];
}
posted @ 2012-06-28 13:49  qingjoin  阅读(587)  评论(0编辑  收藏  举报
  Sportica