• 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
NSTableView - populating from C procedure
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • NSTableView: Out-Of-Bounds Array Error on reloadData
      • From: syntonica <email@hidden>
    • Re: NSTableView - populating from C procedure
      • From: KK <email@hidden>
    • Re: NSTableView - populating from C procedure
      • From: Kyle Sluder <email@hidden>
    • Re: NSTableView - populating from C procedure
      • From: Graham Cox <email@hidden>
  • Prev by Date: Core Animation rendering problem
  • Next by Date: Re: NSTableView - populating from C procedure
  • Previous by thread: Re: Core Animation rendering problem
  • Next by thread: Re: NSTableView - populating from C procedure
  • Index(es):
    • Date
    • Thread