写入磁盘的最快方法 - iOS

时间:2016-01-14 17:03:48

标签: ios objective-c c

我正在使用C函数并希望将数据保存到磁盘。什么是读取和写入此数据的最快方法。我正在将char*intptr_t转换为NSStringNSNumber,将它们存储在字典中,然后将每个字典存储到NSMutableArray中。但是,有没有更快的方法来存储这些数据而无需将值包装在Objective-C对象中?

static void _print_image(const struct mach_header *mh, bool added)
{
    Dl_info image_info;
    int result = dladdr(mh, &image_info);

    if (result == 0) {
        printf("Could not print info for mach_header: %p\n\n", mh);
        return;
    }

    const char *image_name = image_info.dli_fname;
    const intptr_t image_base_address = (intptr_t)image_info.dli_fbase;

    const char *log = added ? "Added" : "Removed";
    //printf("%s: 0x%02lx %s\n\n", log, image_base_address, image_name);

    NSString *imageName = [NSString stringWithUTF8String:image_name];
    NSNumber *baseAddress = [NSNumber numberWithInteger:image_base_address];
    NSDictionary *info = @{@"imageName" : imageName, @"baseAddress" : baseAddress};
    [arr addObject:info];
}

0 个答案:

没有答案