Here's my code:
test.h
@interface testAppDelegate : NSObject <NSApplicationDelegate> {
NSWindow *window;
IBOutlet NSTableView *test;
NSMutableArray *internalArray;
}
@property (assign) IBOutlet NSWindow *window;
@property (nonatomic, retain) NSTableView *test;
-(id) initWithArray: (NSArray*) objects;
-(int)numberOfRowsInTableView:(NSTableView *)aTableView;
-(id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex;
-(void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex;
test.m (top pieces missing for simplicity's sake)
@synthesize window;
@synthesize test;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
PSClient *client = [PSClient applicationClient];
NSURL *url = [NSURL URLWithString:@"http://www.apple.com/main/rss/hotnews/hotnews.rss"];
PSFeed *feed = [client addFeedWithURL:url];
internalArray = [NSMutableArray array];
// Retrieve the entries as an unsorted enumerator
NSEnumerator *entries = [feed entryEnumeratorSortedBy: nil];
PSEntry *entry;
// Go through each entry and print out the title, authors, and content
while (entry = [entries nextObject]) {
[internalArray addObject:entry.title];
//NSLog(@"Entry Title:%@", entry.title);
//NSLog(@"Entry Authors:%@", entry.authorsForDisplay);
[test reloadData];
//NSLog(@"Entry Content:%@", entry.content.plainTextString);
}
}
-(int)numberOfRowsInTableView:(NSTableView *)aTableView{
NSLog(@"%@", [internalArray count]);
return [internalArray count];
}
-(id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
NSString *string = [internalArray objectAtIndex:rowIndex];
NSLog(@"%@", string);
// when I debug, I get same pointers with invalid data
// each object has "name" message
// this following line gives invalid pointer and
// it crashes
return string;
}
-(void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
NSString *string = [internalArray objectAtIndex:rowIndex];
NSLog(@"%@", string);
// when I debug, I get same pointers with invalid data
// each object has "name" message
// this following line gives invalid pointer and
// it crashes
return string;
}
@end
In IB I have the tableview (test) hooked up to the app delegate: test, datasource, and delegate
For some reason the table isn't displaying the data, and when I call [test reloadData]; the app crashes