FROM : Steve Cronin
DATE : Sun May 11 19:36:15 2008
Folks;
I'm an ObjC guy who has to deal with some Carbon code that looks like
this:
#define kVERSION "abc"
#define kPARTNUMBER "123"
...
if ( (p_flag = initSomeSystem (
kVERSION,
kPARTNUMBER,
&errorCode))
== NULL) { ....
What I have to do is makethe kPARTNUMBER a value that is settable by
the user.
No problem collecting the data into NSString *partNumber.
So here's what I've done:
#define kVERSION "abc"
NSString * partNumber = [[blah blah] moreBlah];
.....
const char * cPartNumber = [partNumber
cStringUsingEncoding:NSUTF8StringEncoding];
if( (p_flag = initSomeSystem (
kVERSION,
(char *) cPartNumber,
&errorCode))
== NULL) { ....
Is this correct?
Is there a better way?
When you use a directive like #define x "abc" -> there is an implicit
definition of x as a 'char *', is that correct?
Thanks for adding any clarity,
Steve
DATE : Sun May 11 19:36:15 2008
Folks;
I'm an ObjC guy who has to deal with some Carbon code that looks like
this:
#define kVERSION "abc"
#define kPARTNUMBER "123"
...
if ( (p_flag = initSomeSystem (
kVERSION,
kPARTNUMBER,
&errorCode))
== NULL) { ....
What I have to do is makethe kPARTNUMBER a value that is settable by
the user.
No problem collecting the data into NSString *partNumber.
So here's what I've done:
#define kVERSION "abc"
NSString * partNumber = [[blah blah] moreBlah];
.....
const char * cPartNumber = [partNumber
cStringUsingEncoding:NSUTF8StringEncoding];
if( (p_flag = initSomeSystem (
kVERSION,
(char *) cPartNumber,
&errorCode))
== NULL) { ....
Is this correct?
Is there a better way?
When you use a directive like #define x "abc" -> there is an implicit
definition of x as a 'char *', is that correct?
Thanks for adding any clarity,
Steve
| Related mails | Author | Date |
|---|---|---|
| Steve Cronin | May 11, 19:36 | |
| Nick Zitzmann | May 11, 19:59 | |
| Jens Alfke | May 11, 22:38 | |
| Steve Cronin | May 12, 00:11 | |
| Nick Zitzmann | May 12, 00:14 | |
| Scott Ribe | May 12, 19:41 |






Cocoa mail archive

