I am trying to transfer an NSDictionary from UIViewcontroller to a UIView.
The Dictionary contains the x and y values of a polygon.
The Uiview will plot this polygon.
My problem is that the x y values exist on UIViewcontroller,
they reach the initWithFrame in Uiview,
but can not reach the drawRect in the Uiview.
Please help me.
#import "ViewController.h"
#import "circles_3.h"
#import "draw.h"
@implementation ViewController
@synthesize Core;
- (void)viewDidLoad
{
[super viewDidLoad];
int i;
// Returns NSMutable dictionary with x y points of polygons, some nsstrings and some colors
circles_3 *geo = [circles_3 alloc];
self.Core=[geo updatenum:self.Core];
// Count number of Patches
NSUInteger numObjects = [[self.Core valueForKeyPath:@"Data"] count];
NSArray* filtered=[Core objectForKey:@"Data"];
// Pointer to the UIview class
draw *patch;
// Iterate for all the polygons
for (i=0;i<numObjects;i++)
{
NSDictionary *data = [filtered objectAtIndex:i];
// Sent the data to the draw class for plotting
patch = [[draw alloc] initWithFrame:[[UIScreen mainScreen] bounds] data :data];
[self.view addSubview:patch];
}
}
@end
#import <UIKit/UIKit.h>
#import "ViewController.h"
#define ARC4RANDOM_MAX 0x100000000
@interface draw : UIView
@property NSDictionary * data;
- (id)initWithFrame:(CGRect)frame data:(NSDictionary *)Core;
@end
The UIview class
#import "draw.h"
@implementation draw
@synthesize data;
- (id)initWithFrame:(CGRect)frame data:(NSDictionary *)Core;
{
self = [super initWithFrame:frame];
if (self)
{
self.data=Core;
}
return self;
}
- (void)drawRect:(CGRect)rect
{
// In here i get nil for
self.data
???????????????
}