I have a C API that takes a pointer to arbitrary binary data with function signatures like the following:
void receiveData(const char *data, size_t length);
The bridging header imports this into Swift with the following definition:
func receiveData(data: CString, length: UInt)
I feel I'm missing something basic, but I can't seem to work out how to get a CString from arbitrary NSData - the only options seem to be conversion from NSString or as a string literal. How do I create the CString?
It would make more sense to be able to pass through a CConstPointer<CChar>, but the compiler isn't having a bar of it - is there some way to modify the Swift signature generated by the bridging header?
Edit: CString was removed in Xcode 6 Beta 4. From the release notes:
The CString type has been removed. Values of type const char * are now imported as ConstUnsafePointer instead of CString. C macros that expand to string literals are imported as String.