If GraphView.m is a UIView you won't get very far, as performSegueWithIdentifier:sender
is a UIViewController method.
Assuming that graphView is created from a viewController, you want to set it's delegate to the viewController.
in GraphView.h
declare a graphView protocol above your @interface:
@protocol GraphViewDelegate
-(void)barPlot:(CPTBarPlot *)plot barWasSelectedAtRecordIndex:(NSUInteger)index
@end
declare a property:
@property (weak) id <GraphViewDelegate> delegate;
in GraphView.m:
-(void)barPlot:(CPTBarPlot *)plot barWasSelectedAtRecordIndex:(NSUInteger)index
{
[[self delegate] barPlot:plot barWasSelectedAtRecordIndex:index];
}
in ViewController.h modify the @interface line
@interface MyViewController: UIViewController <GraphViewDelegate>
in ViewController.m
when you create the graphView, set the delegate to self (if graphView is created in Interface Builder, you can CTRL-drag a line to the viewController to set the delegate):
GraphView* graphView = [GraphView alloc] init];
[graphView setDelegate:self];
implement the delegate method as you had it in GraphView (you may not need the index
parameter but I carried it over anyway)..
-(void)barPlot:(CPTBarPlot *)plot barWasSelectedAtRecordIndex:(NSUInteger)index
{
[self performSegueWithIdentifier:@"list2" sender:self];
}
You probably want to modify your method signature, to something like
-(void)graphView:(GraphView*)graphView
didSelectBarAtIndex:(NSUInteger)index
barPlot:(CPTBarPlot *)plot
(it's good practice to send a reference to the sender along with the message)