Reputation: 447
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 the database file correctly? I've been banging my head against this and would appreciate any assistance! 7
Upvotes: 2
Views: 174
Reputation: 59307
Once you get your NSString, call -UTF8String
or -cStringUsingEncoding:
on it to get your C string able to be passed to your sqlite function.
Upvotes: 2