• 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
Help with appending a list to table view with a little bit Objective-C for speed in applescript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help with appending a list to table view with a little bit Objective-C for speed in applescript


  • Subject: Help with appending a list to table view with a little bit Objective-C for speed in applescript
  • From: Bjorn Van Blanckenberg <email@hidden>
  • Date: Mon, 03 Nov 2003 16:55:18 +0100

To append a list to table view I use this call method

set update views of TheDataSource to false
call method "addList:toDataSource:" with parameters {theList,
TheDataSource}
set update views of TheDataSource to true

The problem is that the first column in my table view is an checkbox and
when the list is inserted every item is inserted to the wrong column.

When I append the same list to an table view without the checkbox everything
is inserted in the right column.

Could someone help me in altering the files below so everything is inserted
in the right column with checkbox and explain everything

Thanks

===========================================================================

Create 2 files with this info for the Obj-C call from applescript


/*
* FetchTable.h
*
*/


#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>

@interface NSApplication (ASKATableSupport)

/*- (void)addList:(NSArray *)list toDataSource:(id)dataSource;*/
- (void)addList:(NSMutableArray *)list toDataSource:(id)dataSource;

@end

===========================================================================

/*
* FetchTable.m
*
*/


#import "FetchTable.h"


@implementation NSApplication (ASKATableSupport)

/*- (void)addList:(NSArray *)list toDataSource:(id)dataSource*/
- (void)addList:(NSMutableArray *)list toDataSource:(id)dataSource
{
// Make sure that we have a list with at least one item
if (list && [list count] > 0)
{
// Setup an enumerator for the items in the list
NSEnumerator *listEnumerator = [list objectEnumerator];
if (listEnumerator)
{
// Iterate over each of the items in the list
id items;
while ((items = [listEnumerator nextObject]) != nil)
{
// Make a new data row
id dataRow = [NSClassFromString(@"ASKDataRow")
rowForDataSource:dataSource];
if (dataRow)
{
NSEnumerator *itemEnumerator = [items objectEnumerator];

// Add the data row to the data source
[dataSource addInRows:dataRow];

// Setup an enumerator for each of the items in this
item
if (itemEnumerator)
{
unsigned index = 0;

// Iterate over each of the items
id item;
while ((item = [itemEnumerator nextObject]) != nil)
{
// Make sure there are enough data cells in the
row
if (index < [[dataRow cells] count])
{
// Get a data cell (by index)
id dataCell = [[dataRow cells]
objectAtIndex:index];
if (dataCell)
{
// Set the contents of the data cell
[dataCell setObjectValue:item];
}
}

++index;
}
}
}
}
}
}
}

@end

===========================================================================


--
Oooo.
oooO ( )
( ) ) /
\ ( (_/
\_)


Thanks
Bjorn Van Blanckenberg
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Open-source icons and graphics?
  • Next by Date: Re: NSTableView performance on Jaguar
  • Previous by thread: Re: Open-source icons and graphics?
  • Next by thread: Security Framework: authorization rights.
  • Index(es):
    • Date
    • Thread