• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: C/Obj-C API Confusion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C/Obj-C API Confusion


  • Subject: Re: C/Obj-C API Confusion
  • From: Ken Thomases <email@hidden>
  • Date: Wed, 10 Sep 2008 14:57:54 -0500

On Sep 10, 2008, at 2:44 PM, J. Todd Slack wrote:

I had a conversation with an Apple Engineer a few days ago and he recommended that I switch to the Quicktime C API rather than the Objective-C api for what I needed to do.

I have a few questions.

1. Currently I have a .m and I use NSTask, NSString, etc. I would need to change these for C, correct? What is NSTask in the C API?

2. Am I confused?

3. Can one mix C and Objective-C in the same file? Maybe I can keep the Objective-C stuff I already have done and just write the c code for QT integration that I need? If I pass in an NSString from AppleScript do I need to convert it a C-String?

Objective-C is a superset of C. Anything you can do in C you can also do in Objective-C.


You do not necessarily need to abandon all Objective-C/Cocoa just because you want to use a C API. In fact, some parts of Cocoa are presented as a C API -- they're plain functions.

However, you may need to do some conversions, yes. When you want a C string and you have an NSString, you need to know in what encoding you need the C string. Very often in the Mac APIs, you want UTF-8. To get a UTF-8-encoded C string from an NSString, use the -UTF8String method. If you need to get a POSIX path from an NSString, use - fileSystemRepresentation, instead.

Cheers,
Ken

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >C/Obj-C API Confusion (From: "J. Todd Slack" <email@hidden>)

  • Prev by Date: Re: C/Obj-C API Confusion
  • Next by Date: Re: menu with checkbox
  • Previous by thread: Re: C/Obj-C API Confusion
  • Next by thread: Accessibility Voiceover questions
  • Index(es):
    • Date
    • Thread