开发者

Finding a file path in c

开发者 https://www.devze.com 2023-03-28 00:25 出处:网络
I\'m working on an iOS project and need to supply a file path for a sqlite call in a c function.I know for objective-c calls, you can use a function like this one to get the path:

I'm working on an iOS project and need to supply a file path for a sqlite call in a c function. I know for objective-c calls, you can use a function like this one to get the path:

+ (NSString *) FilePath:(NSString *) fileName {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    return [documentsDirectory stringByAppendingPathComponent:fileName];
}

I can't use this function in my c as it has to remain as-is (no obj-c). Is there a similar type of call in c, or is there a build setting in xcode4 to help put the code access t开发者_如何学运维he database file correctly? I've been banging my head against this and would appreciate any assistance! 7


Once you get your NSString, call -UTF8String or -cStringUsingEncoding: on it to get your C string able to be passed to your sqlite function.

0

精彩评论

暂无评论...
验证码 换一张
取 消