ios - Is there a way for having the same string readable and editable from C and Objective-C? -
i have following problem: ios app written objective-c (as usual) uses parts of code written c. c code core of application, code written objective-c uses job done c , coordinates whole application.
for doing job, c code reads preferences file, name cabled in c file. possible (in c code) read name of file @ run-time rather @ compile-time? idea modify string objective-c , let c code read string.
assuming .c file looks this:
#include <stdbool.h> static const char *_prefsfilename = "userprefs.css"; bool readprefs() { file *fp = fopen(_prefsfilename, "r"); .... } then need add function allow _prefsfilename set before attempt made use open file:
void setprefsfilename(const char *prefsfilename) { _prefsfilename = prefsfilename; } and ensure call before calling readprefs().
this assumption of course, that's have work with.
Comments
Post a Comment