标签: initwithcontentsoffile

在c ++中的文件(日志文件)中添加新行

我有一个日志功能,在这里我有日志文件.现在,每次运行程序时,我都希望以前写入的文件不会被删除,并且应该附加当前数据(日志文件中有什么)

只是为了说清楚例如:我有一个日志文件logging_20120409.log,它每天保存时间戳.假设我运行我的项目,它会将当前时间戳写入其中.现在,如果我重新运行它,之前的时间戳将被替换.我不想要这个功能.我想要上一个时间戳和当前时间戳.

请帮忙

c++ file append initwithcontentsoffile

28
推荐指数
2
解决办法
5万
查看次数

UIImage initWithContentsOfFile不起作用

我有疑问:我想避免[UIImage imageNamed:].所以我做了:

UIImage *prodImg = [[UIImage alloc] initWithContentsOfFile:@"myimage.png"]; 
controller.productImg.image = prodImg;  
[prodImg release];
Run Code Online (Sandbox Code Playgroud)

但现在图像不再显示了.

有谁知道如何让它工作?

xcode objective-c uiimage imagenamed initwithcontentsoffile

12
推荐指数
1
解决办法
1万
查看次数

如何从应用程序中本地访问json文件

我试图找出如何在应用程序内本地访问json文件.目前我一直在从这样的服务器远程使用json文件:

jsonStringCategory = @"http://****categories?country=us";
    }

    // Download the JSON file
    NSString *jsonString = [NSString
                            stringWithContentsOfURL:[NSURL URLWithString:jsonStringCategory]
                            encoding:NSStringEncodingConversionAllowLossy|NSUTF8StringEncoding
                            error:nil];

    NSLog(@"jsonStringCategory is %@", jsonStringCategory);

    NSMutableArray *itemsTMP = [[NSMutableArray alloc] init];

    // Create parser 
    SBJSON *parser = [[SBJSON alloc] init];
    NSDictionary *results = [parser objectWithString:jsonString error:nil];

    itemsTMP = [results objectForKey:@"results"];

    self.arForTable = [itemsTMP copy];

    [self.tableView reloadData];
Run Code Online (Sandbox Code Playgroud)

我试过这个:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"categoriesus" ofType:@"json"];


    jsonStringCategory = [[NSString alloc] initWithContentsOfFile:filePath];
Run Code Online (Sandbox Code Playgroud)

谢谢

iphone json objective-c initwithcontentsoffile ios

0
推荐指数
1
解决办法
4582
查看次数