Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: understanding conversions between CF and NS datatypes



On Aug 29, 2008, at 11:38 AM, Allen Curtis wrote:

I am writing a Cocoa application for accessing a serial device. (IOKit) In
order to do this, you need to translate between CF and NS data types. (I
believe)


For instance:
CFMutableArrayRef devicePaths = CFArrayCreateMutable(NULL, 0, NULL);


       GetSerialPortPaths(serialServices, devicePaths);  // Fills in
CFMutableArray
       serialPorts = (NSMutableArray *) devicePaths;
       //CFRelease(devicePaths);
       printf("Found %d serial ports\n", [serialPorts count]);

The problem: I found that if you release the CFMutableArray, you also loose
the NSMutableArray

Yep, because you're merely casting types, you're not creating a new object.


Question:
1. Where can I get a better understanding of the data conversion between
these different frameworks?

Does <http://developer.apple.com/documentation/Cocoa/Conceptual/CarbonCocoaDoc/Articles/InterchangeableDataTypes.html > help?


2. Ultimately the device path names will appear in a ComboBox. Was it
necessary to convert the CFMutableArray to a NSMutableArray for the
datasource function?

I don't know about "necessary", but it's certainly convenient, because then you can use the (IMO) more convenient accessors of NSArray.


_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >understanding conversions between CF and NS datatypes (From: "Allen Curtis" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.