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: NSTableView and displaying c strings



On Nov 30, 2007, at 3:23 PM, Chinh Nguyen wrote:

What I did for my tableView:objectValueForTableColumn:row: method is convert the c string for a given column and row to an NSString and return it (my simplified example assumes just one column).

// VarName() is a wrapper for returning the pointer to a null- terminated c string given an index
string = [[NSString alloc] initWithCString:VarName(row)
encoding:NSMacOSRomanStringEncoding];
return(string);
}

You can use [NSString stringWithCString:encoding] instead of [NSString initWithCString:encoding] and the returned string will be autoreleased (that is, released "later") and then you won't have to worry about the reference count.


And while you can't change the format of the code today, you may want to consider a plan to migrate your data to UTF-8 at the least (or perhaps it already is and your just using the wrong encoding above?).
--
David Duncan
Apple DTS Animation and Printing
email@hidden




_______________________________________________

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: 
 >NSTableView and displaying c strings (From: Chinh Nguyen <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.