Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > TableViews with external (Postgres) data

TableViews with external (Postgres) data
Thread Tools
Senior User
Join Date: Feb 2003
Location: USA
Status: Offline
Reply With Quote
Feb 5, 2006, 05:33 PM
 
I'm working on an app that accesses PostreSQL data (Cocoa/ObjC). I'm not using anybody's framework, I more or less used postgres' C lib and wrote my own class to access the data. The class returns an array of dictionaries, which is usually loaded up in tables and/or text fields. I've just started running into sort problems in the table views. Basically, dates and ints are not sorting as expected (it's not a locale problem). I'm quite certain that the tables aren't sorting right because they're doing a string sort, which would of course be different from doing an actual date or integer sort. I can work around it, but it requires me to hit the database to reload the data using a specialized "order by" statement. In the case of integers I have to specify "order by int8(odrnum)" rather than plain old "order by ordnum". Either way it's terribly inefficient to do things that way. Basically I should be able to sort the table using -(void)tableViewNSTableView *)tableView sortDescriptorsDidChangeNSArray *)oldDescriptors, but that doesn't handle the sort correctly.
So I've resorted to hitting the db every time the user sorts the table, using specialized sort statements for each table column, and having to set the little sort arrow in the column header manually. It feels very hackish...
I know this is not nearly enough information, this is a very specific problem. But I'm hoping a fresh set of eyes might uncover a way of dealing with this that I'm not thinking of, I'm sure I'm not seeing the forest for the trees.
Maybe I should be investigating re-casting the data in the arrays, or sorting the array manually and reloading the table, or going to the kitchen for another glass of Chardonnay, I don't know...


Thanks in advance for any feedback, flames, dumb looks, etc.
     
Professional Poster
Join Date: Oct 1999
Location: :ИOITAↃO⅃
Status: Offline
Reply With Quote
Feb 23, 2006, 07:56 PM
 
Yeah, it seems to me that you want to have your class examine the type of the table column and handle conversion to NSDate or NSNumber, etc.
     
Senior User
Join Date: Feb 2003
Location: USA
Status: Offline
Reply With Quote
Feb 26, 2006, 05:49 PM
 
I've put it on the back burner for now, but I do believe that I'm going to have to do some conversions in order to get the sort working. Connecting to the db server for each sort isn't very efficient....
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:27 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2