Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 946615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:56:50+00:00 2026-05-15T22:56:50+00:00

Im using core-plot for my graphing component of my iPhone app, and I have

  • 0

Im using core-plot for my graphing component of my iPhone app, and I have been using NSDecimal object a lot.

One of the lines of their code that I have seen is like this:

-(void)plotPoint:(NSDecimal *)plotPoint forPlotAreaViewPoint:(CGPoint)point
{
    NSDecimal x;
    //do some calculations on x
    plotPoint[CPCoordinateX] = x;
}

Where, CPCoordinateX is deinfed as below:

typedef enum _CPCoordinate {
    CPCoordinateX = 0,  ///< X axis
    CPCoordinateY = 1,  ///< Y axis
    CPCoordinateZ = 2   ///< Z axis
} CPCoordinate;

The line:

plotPoint[CPCoordinateX] = x;

is what I dont understand, how can a NSDecimal be assigned to like this?

In my code, Im trying to call this method, like so:

NSDecimal dec = CPDecimalFromInteger(0);
[plotSpace plotPoint:&dec forPlotAreaViewPoint:point];
NSDecimalNumber *newx = [[NSDecimalNumber alloc] initWithDecimal:dec];

NSDecimal x = dec[CPCoordinateX];
//NSLog(@"converted at: %@", newx);

but Im getting compile errors:

error: subscripted value is neither array nor pointer

Can someone please explain this to me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:56:50+00:00Added an answer on May 15, 2026 at 10:56 pm

    plotPoint is a pointer and pointers can be indexed like arrays using the subscript operator:

    int array[] = { 1, 2, 3 };
    NSLog(@"x=%d, y=%d, z=%d", array[0], array[1], array[2]); 
    // prints "x=1, y=2, z=3"
    int *pointer = array; // implicit conversion to pointer
    NSLog(@"x=%d, y=%d, z=%d", pointer[0], pointer[1], pointer[2]);
    // also prints "x=1, y=2, z=3"
    

    You can also use those expressions for assignments:

    array[0] = 4;
    pointer[1] = 5;
    

    But you can only use the subscript operator on arrays or pointers:

    NSDecimal dec = CPDecimalFromInteger(0);
    dec[0]; // illegal, dec is a single NSDecimal value, not pointer or array
    

    To actually pass a point -plotPoint:forPlotArrayViewPoint: you need a C-style array or a dynamic array of 2 or 3 NSDecimals (according to what dimensions the method expects), e.g.:

    NSDecimal decPoint[] = {
         CPDecimalFromInteger(0),
         CPDecimalFromInteger(0),
         CPDecimalFromInteger(0)
    };
    [plotSpace plotPoint:decPoint forPlotAreaViewPoint:point];
    

    On that array you can now also use the subscript operator:

    NSDecimal x = decPoint[CPCoordinateX];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an iOS app using Core Plot headers. I have different UI for
Hi have followed this tutorial using Core plot framework http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application My project compiles, but
I am using core plot to make a line graph for my iPhone app.
In iPhone App i am using core Plot vertical bar chart. How to Remove
I have slider in one view and Bar chart using core plot in its
I have read the tutorials about making 2D BarGraph using Core Plot in iPhone.
I am using core plot in one of my iPhone projects. Is it possible
I've been using Core Plot to draw some charts for an iOS app I've
I'm using Core Plot to do some graphing in an iOS app. I'm in
I am trying to follow this tutorial ( Using-core-plot-in-an-iphone-application ). When I try to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.