i'm failing to sort the xml data on my tableview. am i suppose to make a model class for the data and have the table view display/sort that instead? i'm quite with this one. am i suppose to enter values in Sort Key and Selector IB fields for each column? doing so returns: -[NSXMLElement compare:]: unrecognized selector sent to instance 0x162b6430. what am i missing here?
- (IBAction)parseData:(id)sender { [progressIndicator setHidden:NO]; [progressIndicator startAnimation:nil]; NSURL *url = [NSURL URLWithString:kXMLWebAddress]; NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30]; //cachePolicy: 10.5 or higher NSData *urlData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:nil error:nil]; NSXMLDocument *doc = [[NSXMLDocument alloc] initWithData:urlData options:0 error:nil]; [itemNodes release]; itemNodes = [[doc nodesForXPath:@"stations/station" error:nil] retain]; [tableView reloadData]; [progressIndicator setHidden:YES]; [progressIndicator stopAnimation:nil]; } - (void)dealloc { [itemNodes release]; [super dealloc]; } - (NSString *)stringForPath:(NSString *)xPath ofNode:(NSXMLNode *)node { NSError *error; NSArray *nodes = [node nodesForXPath:xPath error:&error]; if ([nodes count] == 0) return nil; else return [[nodes objectAtIndex:0] stringValue]; } #pragma mark - #pragma mark Table View Datasourse Methods - (int)numberOfRowsInTableView:(NSTableView *)theTableView { return [itemNodes count]; } - (id)tableView:(NSTableView *)theTableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row { NSXMLNode *node = [itemNodes objectAtIndex:row]; NSString *xPath = [tableColumn identifier]; return [self stringForPath:xPath ofNode:node]; } - (void)tableView:(NSTableView *)aTableView sortDescriptorsDidChange:(NSArray *)oldDescriptors { [itemNodes sortUsingDescriptors:[aTableView sortDescriptors]]; [aTableView reloadData]; } _______________________________________________ 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