I know this has been discussed before, but I have been going through the issue 
of reloadData and datasource methods not running. I cannot figure out what is 
going on with my datasource methods.
Everything is connected. But when on [segmentTableView reloadData], no 
datasource method is run.
 After the application was running, I debugged the code and checked the classes 
of SelectorController and TableSource. They are all connected in runtime.For 
table view, I only connected it to SelectorController -> segmentTableView, and 
its dataSource to SelectorController -> segmentTableView. All of them are 
connected properly in runtime.In Log, when I print the datasource and delegate 
of SegmentTableView, it shows SelectorController.

This is troublesome as I have 4 other tables in the same application that are 
loaded properly through their dedicated datasources.
It is only in this table that nothing is working. What am I missing? Your help 
is invaluable.


Her is some of the relevant code:


// SelectorController.h
#import <Cocoa/Cocoa.h>
@classsegmentIndustry;


@interface SelectorController : NSObject {
NSMutableArray *segmentIndustryData;
IBOutletNSTableView *segmentTableView;
IBOutletNSArrayController *segmentDataController;

IBOutletNSButton *stockSelectButton;
intmodelRS;

}

-(void) insertObject:(segmentIndustry *) s inSectorDataAtIndex:(int)index;

-(IBAction) initializeSectorSegmentData:(id) sender;
@end



// SelectorController.m



#import "SelectorController.h"
#import "segmentIndustry.h"
#import "MyDocument.h"


NSDictionary *segmentDict;


@implementation SelectorController


- (id)init
{
self = [superinit];
if (self) {

// Add your subclass-specific initialization here.
// If an error occurs here, send a [self release] message and return nil.
segmentDict =[NSMutableDictionarydictionary];
[segmentDictretain];

}
return (self);
}
- (void)awakeFromNib
{
segmentIndustryData=[[NSMutableArrayalloc] init];
[segmentIndustryDataretain];
segmentDataController=[[NSArrayControlleralloc] init];
[segmentDataControllerretain];


}
//Load into TableView in the GUI
#pragma mark Table view dataSource methods


- (int) numberOfRowsInTableView:(NSTableView *) TableView
{
return [segmentIndustryDatacount];

}


-(id)tableView:(NSTableView *)aTableView
ObjectValueForTableColumn:(NSTableColumn *)aTableColumn
 row:(int)rowIndex
{

NSString *identifier =[aTableColumn identifier];
segmentIndustry *stock =[segmentIndustryDataobjectAtIndex:rowIndex];
return [stock valueForKey:identifier];

}


-(void) tableView:(NSTableView *) aTableView
 setObjectValue:(id)anObject
 forTableColumn:(NSTableColumn *) aTableColumn
 row:(int) rowIndex
{
NSString *identifier =[aTableColumn identifier];
//What stock?
segmentIndustry *stock =[segmentIndustryDataobjectAtIndex:rowIndex];
[stock setValue:anObject forKey:identifier];

//Set the value for the attribute named identifier
}







-(IBAction)initializeSectorSegmentData:(id) sender
{
segmentDict=[[MyDocumentgetSectorSegmentData:(id) sender] mutableCopy];
[segmentDictretain];
NSWindow *w =[segmentTableViewwindow];
[wmakeKeyWindow];
//Fill the table row by row;
int i=0;
NSMutableArray *aXtemp;
if ([segmentIndustryDatacount]>0) [segmentIndustryDataremoveAllObjects];
[[segmentDataControllercontent] removeAllObjects];
for (idkeyinsegmentDict)
{
aXtemp = [NSMutableArrayarrayWithArray:[(NSArray 
*)[segmentDictobjectForKey:key] mutableCopy]];
if ([(NSString *) [aXtemp lastObject] intValue]== modelRS) {
[aXtemp insertObject:(NSString*) keyatIndex:(NSUInteger)1];
segmentIndustry *s = [[segmentIndustryalloc] init];
[s setSegName:(NSString *)[aXtemp objectAtIndex:(NSUInteger) 0]];
[s setSegOther:(NSString *)[aXtemp objectAtIndex:(NSUInteger)1]];
[s setSegIndustry:(NSString*)[aXtemp objectAtIndex:(NSUInteger)2]];
[s setSegSector:(NSString *)[aXtemp objectAtIndex:(NSUInteger) 3]];
// Add it to the content array of 'stockDataController'
[segmentDataControlleraddObject:s];
[selfinsertObject: s inSectorDataAtIndex:(int)i];
++i;
}
}

//Re-sort (in case the user has sorted a column
[segmentDataControllerrearrangeObjects];

// Get the sorted array

 NSArray *a = [segmentDataController arrangedObjects];
 for ( i=0;i<[a count];++i) {
[segmentTableView editColumn:0 row:i withEvent:nil select:YES];

[segmentTableViewreloadData];

}




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to