I want to develop an application in which firstly i was develop an structure code for storing X and y axis.
struct TCo_ordinates
{
float x;
float y;
};
.
Then in drawRect method i generating an object of structure like.
struct TCo_ordinates *tCoordianates;
Now I drawing the graph of Y-Axis its code is.
fltX1 = 30;
fltY1 = 5;
fltX2 = fltX1;
fltY2 = 270;
CGContextMoveToPoint(ctx, fltX1, fltY1);
CGContextAddLineToPoint(ctx, fltX2, fltY2);
NSArray *hoursInDays = [[NSArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12", nil];
for(int intIndex = 0 ; intIndex < [hoursInDays count] ; fltY2-=20, intIndex++)
{
CGContextSetRGBStrokeColor(ctx, 2, 2, 2, 1);
//CGContextSetRGBStrokeColor(ctx, 1.0f/255.0f, 1.0f/255.0f, 1.0f/255.0f, 1.0f);
CGContextMoveToPoint(ctx, fltX1-3 , fltY2-40);
CGContextAddLineToPoint(ctx, fltX1+3, fltY2-40);
CGContextSelectFont(ctx, "Helvetica", 14.0, kCGEncodingMacRoman);
CGContextSetTextDrawingMode(ctx, kCGTextFill);
CGContextSetRGBFillColor(ctx, 0, 255, 255, 1);
CGAffineTransform xform = CGAffineTransformMake(
1.0, 0.0,
0.0, -1.0,
0.0, 0.0);
CGContextSetTextMatrix(ctx, xform);
const char *arrayDataForYAxis = [[hoursInDays objectAtIndex:intIndex] UTF8String];
float x1 = fltX1-23;
float y1 = fltY2-37;
CGContextShowTextAtPoint(ctx, x1, y1, arrayDataForYAxis, strlen(arrayDataForYAxis));
CGContextStrokePath(ctx);
Now i want to store generated the values of x1 and y1 in NSMutableArray dynamically, for that i was written the code.
NSMutableArray *yAxisCoordinates = [[NSMutableArray alloc] autorelease];
for(int yObject = 0; yObject < intIndex; yObject++)
{
[yAxisCoordinates insertObject:(tCoordianates->x = x1,tCoordianates->y = y1) atIndex:yObject];
}
But it didn't working. How i store the x1 and y1 values in yAxisCoordinates object.
The above code is correct?????????????