0

I am working on mapView project. My project will take only 5 annotations on the map. Once new annotation will be added, then first annotation will be drop. I am keeping all annotations latitude and longtitude into NSMutableStringArray. Is there any short way to implement this round robin fashion. First in last out.

for example my nsmutable string:

 [12.99, 35.97: 35.85,94.53: 45.44,98.91]

How could I delete first object (each string separated by column operator :) from the string to acquire the following:

 [35.85,94.53: 45.44,98.91]
4

2 に答える 2

0

私はそれを機能させました、私の解決策は以下の通りです:

NSMutableString *absolute=[NSMutableString stringWithString:pinPoints];
          NSLog(@"before absolute: %@",absolute);

          NSArray *placemarks=[absolute componentsSeparatedByString:@":"];
          if([placemarks count]>5)
          {
          //NSLog(@"%@",[placemarks objectAtIndex:0]);
          NSMutableString *string1 = [NSMutableString stringWithString: [placemarks objectAtIndex:0]];
          [absolute replaceOccurrencesOfString:string1 withString:@"" options:0 range:NSMakeRange(0,[pinPoints length])];
          pinPoints=absolute;
          }
          NSLog(@"after absolute: %@",absolute);
于 2012-11-04T18:35:28.027 に答える
0

NSMutableArrayそれ自体を使用することの何が問題なのですか。または多分私はあなたの質問を理解していませんか?

NSMutableArray *queue = [[NSMutableArray alloc] init];

if([queue count] >= 5)
    [queue addObject: myObject];  // adds at end
else
    object = [queue objectAtIndex:5];  // take out the first added object
    [queue removeObjectAtIndex:0];
于 2012-11-04T18:05:09.560 に答える