Finding a file path in c
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.
精彩评论