Using a C ++ library in an Objective-C application?
I am planning on learning Objective-C to write an OS X application, but it will depend on a library written in C ++. Can I interact with C ++ in an Objective-C application? I am new to desktop development.
The C ++ library will be used simply to parse a file and return some data about that file. For example, in the example of compiled libraries in the terminal, you should type
./xlsanalysis my_spreadsheet.xls
and it returns:
rows: 34
columns: 10
first row: "My Spreadsheet header"
Is it possible to include this library directly in an Objective-C application or interface with it in some way?
source to share
Objective-C ++ exists for this purpose, for example. Objective-C plus C ++ (or vice versa). From Objective-C ++ files (like .mm files) you have full access to all C ++ functionality. Be careful when choosing types from C ++ to Objective-C for example. you should convert C ++ string
to NSString
using something like [NSString stringWithCString:cPlusPlusString.c_str()]
. Another direction will be string cPlusPlusString([objectiveCString cString])
(or cStringUsingEncoding:
).
source to share