I am using a core plot for the graphing component of my iPhone app, and I NSDecimal too many objects.
I have seen their line of code:
- (zero) plot point: (NSDecimal *) plotpoint forPlotAreaViewPoint: (CG point) point {NSDCC x; // calculate something on X plot point [CPCoordinateX] = x; } Where, CPCoordinateX has been deenified as below:
typedef enum _CPCoordinate {CPCoordinateX = 0, /// & lt; X-axis CPCoordinateY = 1, /// & lt; Y axis CPCoordinateZ = 2 /// & lt; Z axis) CPCoordinate; line:
plot point [CPCoordinateX] = x; What I can not understand, how can one NSDCimal be allocated to do so?
In my code, I am trying to call this method, such as:
NSDecimal dec = CPDecimalFromInteger (0); [Plot space point point: & amp; Doc forPlotAreaViewPoint: point]; NSDecimalNumber * newx = [[NSDecimalNumber alloc] initWithDecimal: dec]; NSDecimal x = dec [CPCoordinateX]; // NSLog (@ "Converted to:% @", NewX); but I am compiling errors:
Error: Subscript Value Any Array or Pointer
< P> Can anyone please explain this to me?
plot point is an indicator and points can be indexed as That array using the subscript operator:
int array [] = {1, 2, 3}; NSLog (@ "x =% d, y =% d, z =% d", array [0], array [1], array [2]); // print "x = 1, y = 2, z = 3" int * pointer = array; // Untrue conversion on pointer NSLog (@ "X =% d, y =% d, z =% d", indicator [0], indicator [1], indicator [2]); // You can also use the expressions "x = 1, y = 2, z = 3" for the assignment: array [0] = 4; Indicator [1] = 5;
But you can use the subscript operator only on arrays or pointers:
NSDecimal dec = CPDecimalFromInteger (0); Dec [0]; // Invalid, DC is a single NSDcubal value, not for indicator or array
To actually pass a point -plotPoint: forPlotArrayViewPoint: A C-style array is required or a dynamic array of 2 or 3 NSDecimal s (according to the method what dimensions are expected), such as:
NSDecimal decPoint [] = {CPDecimalFromInteger (0), CPDecimalFromInteger (0), CPDecimalFromInteger (0)}; [Plot space point point: docpoint for plotaireva viivant: point];
Now you can also use the subscript operator on that array:
NSDecimal x = decpoint [CPCoordinateX];
Comments
Post a Comment