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


_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to