[futurebasic] Re: [FB] Dynamic arrays

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 2014 : Group Archive : Group : All Groups

From: Robert Covington <artlythere@...>
Date: Wed, 22 Oct 2014 15:09:14 -0400
On Oct 22, 2014, at 2:13 PM, Brian S <fblistserve@...> wrote:

> 
> On Oct 22, 2014, at 4:14 AM, Bernie <fblist.bw@...> wrote:
> 
>> rc wrote:
>> 
>>> dim dynamic gTableRowData(_maxCols,_maxInt) as tableRowDataRec
>>> 
>>> Will just swap to an array of Dictionaries I guess (key value pairs for identifier and value)
>> 
>> Array of dicts is defintely the way to go for table view data (IMO). Matching dict keys and table column identifiers makes the data source objectValueForTableColumn: method simple:
>> 
>> - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex {
>>    return [[tableViewData objectAtIndex:rowIndex] objectForKey:[aTableColumn identifier]];
>> }
> Agreed. The tableView delegate methods are quite handy and virtually do all the work. Also, tableView methods can be used for multiple tableviews and not just one. 
> 
> Brian

That's the next step.

I wasn't provided the source data to know how best to load things up. so figured the asked of my efforts would have his data in some format more compatible to that.  But dictionary is the way to go for sure, given the key-value setup.

To address the other mention, Yes  that icky stuff is the code FBtoC generates for a dynamic array. If you've ever thought you can just use regular FB dynamic array statements within BeginC/EndC C code, like int var =  gSomething[index]; you get a big surprise. You have to pull out the FbtoC code generated in your file.m , and finesse that into place per your need because unlike a regular defined array, there's a lot more gunk to it, including that funky *(void*) stuff. In this case, it created a CFStringRef type pointer). And it's even funkier with array checking on.

That pointer gunk was FBtoC generated from something like this in FB code.

dim testRef as CFStringRef

testRef = gTableViewData(col,row) // where rows was dimmed as _maxInt, cols was 12 or so)

rc