I need to write a DLL (dynalib, whatever) for OS X 10.6 (Snow Leopard) or later The DLL reads and writes a binary file. (It's the company's proprietary format.) It'll be used by an app that's all Cocoa (AFIK). Everything 64 bit only.
From reading Apple's docs, books, and asking questions here, I still don't have a clear and confident idea as to the good, proper way to deal with binary files. I have the impression I can't use the standard unix/C fopen(), fread() or open(), read() etc. Or I can but 开发者_StackOverflowI'd be asking for trouble. Is this true? Should I be using something else, and just what?
I have the impression I can't use the standard unix/C fopen(), fread() or open(), read() etc.
The POSIX/BSD personality is fully supported by the operating system. Feel free to write standards compliant C.
Foundation Kit has Objective-C classes and messages you can use (NSData
, NSFile
, etc), however they are often more of a pain to use especially when you are maintaining portable code amongst platforms. There is also the side-effect of Objective-C being somewhat easier to reverse engineer than straight C (a trait shared by all higher-level languages).
Depending on the needs of your library, you can consider wrapping it into a Framework as opposed to a naked dylib
.
精彩评论