NSTableView - populating from C procedure
NSTableView - populating from C procedure
- Subject: NSTableView - populating from C procedure
- From: Alexander Bokovikov <email@hidden>
- Date: Thu, 23 Jul 2009 11:41:22 +0600
Hi, All,
This is my first attempt to deal with Cocoa container class, so I have
some unclear points. I've found one of many tutorials here:
http://www.cocoadev.com/index.pl?NSTableViewDataSource
where it is said, among other, that NSTableView items may be filled
out like this:
- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex {
return [[myTableViewArray objectAtIndex: rowIndex] objectForKey:
[aTableColumn identifier]]
}
My specifics is that the data (strings) are delivered by an external
procedure, located out of ObjC stuff, and returning C-style strings.
My table has only one column. My question is, as usual, about memory
manager: May I write something like this:
exern void getString(int row, char *s, int *len);
- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex {
char buf[255];
int len;
getString(rowIndex, buf, &len);
return [NSString stringWithCString:buf length:len
encoding:NSUTF8StringEncoding];
}
I.e. is it possible to return a NSString without its preliminary
retaining?
Or should I add [... retain] to the returning string?
All examples operate by some values, stored in retained structures,
like NSArray. Here my question originates from.
Thanks.
_______________________________________________
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