Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
5020
Behavior of removeItemAtIndex and insertItemAtIndex
posted

Hi,

If I have a series/data-source with 100 items and I call:

[self.chartView removeItemAtIndex:0] // A1

[self.chartView removeItemAtIndex:0] // A2

[self.chartView removeItemAtIndex:0] // A3

What is the behavior? Does A2/A3 do anything?

Is it the same as calling?

[self.chartView removeItemAtIndex:2] // B1

[self.chartView removeItemAtIndex:1] // B2

[self.chartView removeItemAtIndex:0] // B3

Or...

[self.chartView removeItemAtIndex:0] // C1

[self.chartView removeItemAtIndex:1] // C2

[self.chartView removeItemAtIndex:2] // C3

Parents
No Data
Reply
  • 21382
    Verified Answer
    posted

    Hello Caylan,

    The chartView would act as any other list would act given the removeAt action 

    Given a list {A, B, C, D, E, F};

    Then your first code would end up with List { D, E, F} remaining after the 3 actions.  The first action removes A, now the first item in the list is B. The second item removes the first item in the list (B), which makes C the new first item.

    The second would give you the same ending list as the first, {D E F} but would do it backwards, removing C, then removing B, then removing A.

    The third bit of  code would end up jumping items.  So your result set would be {B, D, F}

Children
No Data