I have the following UIViewController class:
FILE: ResultsDataViewController.h
@interface ResultsDataViewController : UIViewController
@property (nonatomic, strong) NSString* name;
@end
FILE : ResultsDataViewController.m
#import "ResultsDataViewController.h"
@interface ResultsDataViewController ()
@end
@implementation ResultsDataViewController
@synthesize data;
Then I have my UIView with class name Plot.h/m
Plot.h:
@interface PlotGraph : UIView <CPTBarPlotDataSource, CPTBarPlotDelegate>
@property (nonatomic, strong) NSString* receivedName;
@end
Plot.m:
#import "Plot.h"
@interface Plot()
@end
@implementation PlotGraph
@synthesize receivedName;
…
=====
Question:
HOW do I pass the value of name from my UIViewController and assign it to the variable receivedName in my UIView?
The UIView Plot is a view in my UIViewController DataViewController
(Note:
@synthesize data;in your question is probably a typo. I’ll assume you meant@synthesize name;. Also,@interface Plot()should probably be@interface PlotGraph().)First, you need to have a reference to a
PlotGraphobject either as something you create in code or something that you load into anIBOutletvariable from your xib file or storyboard. Once you have that, either where you create it or inviewDidLoad:, it’s simply something like: