我有一个c代码.我给出了一个数组索引为12.但是它允许我将数组初始化为更多的索引而不是为索引输出错误.任何人都可以向我解释它是否正在发生.
int vas1[12][12];
vas1[15][15]=0;
int i,j;
for (i = 0; i < 15; i ++)
{
for (j = 0; j < 15; j ++) {
printf("i=%d j=%d vas=%d",i,j,vas1[i][j]);
}
}
printf("Success");
Run Code Online (Sandbox Code Playgroud)
谢谢
我想获得mapkit中两点之间的路线!我做了一些谷歌工作,发现了这个:-http://spitzkoff.com/craig/?p = 108
我用它来显示地图和图钉: -
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationController.navigationBarHidden=NO;
self.title=@"Map";
CLLocationCoordinate2D location;
location.latitude=[latLabel doubleValue];
location.longitude=[longLabel doubleValue];
MKCoordinateRegion region;// = MKCoordinateRegionMakeWithDistance(CLLocationCoordinate2DMake((location.latitude) / 2.0, (location.longitude) / 2.0), 1000.0, 1000.0);
region.center=location;
region.span.latitudeDelta =0.1;
region.span.longitudeDelta =0.1;
addAnnotation=[[AddressAnnotation alloc] initWithCoordinate:location];
NSLog(@"city=mapview=>%@",City);
NSLog(@"adress=mapview=>%@",Address);
addAnnotation.title=City;
addAnnotation.subtitle=Address;
[mapView addAnnotation:addAnnotation];
[mapView setRegion:region animated:YES];
}
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(AddressAnnotation *) annotation
{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.pinColor=MKPinAnnotationColorRed;
annView.draggable=TRUE;
annView.animatesDrop=TRUE;
annView.canShowCallout=YES;
annView.calloutOffset=CGPointMake(-5,5);
annView.draggable=TRUE;
return annView;
}
Run Code Online (Sandbox Code Playgroud)
并且注释类显示名称和地址.但是我应该如何添加更多以显示两点之间的路径.
请帮我.
提前致谢
我编辑的问题: - 我复制了数组.但问题是当下面的行执行[mainRestaurantArray removeObjectAtIndex:j]; mainRestaurantArray的索引是reduce.And将不允许删除正确的索引值
因为它显示索引出错的错误.Becoz arrayRestaurantList -31的总索引和mainRestaurantArray-25的总索引(删除重复值后).
if([arrayRestaurantList count]==[mainRestaurantArray count]){
BtnMore.hidden=YES;
TablView.frame=CGRectMake(0,57, 320, 360);
} else{
[mainRestaurantArray removeAllObjects];
mainRestaurantArray=[[NSMutableArray arrayWithArray:arrayRestaurantList] retain];
if ([arrayRestaurantList count]>10) {
for (int i=0;i<[arrayRestaurantList count]-10;i++) {
NSString *Old_data;
Old_data=[[arrayRestaurantList objectAtIndex:i] objectForKey:@"Name"];
NSLog(@"olddata==>%@",Old_data);
for (int j=[arrayRestaurantList count]-10;j<[arrayRestaurantList count];j++) {
NSString *New_data;
New_data=[[arrayRestaurantList objectAtIndex:j] objectForKey:@"Name"];
NSLog(@"olddata==>%@ newdata==>%@",Old_data,New_data);
if ([New_data isEqualToString:Old_data]) {
//BtnMore.hidden=YES;
[mainRestaurantArray removeObjectAtIndex:j];
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个NSMutableArray
(mainRestaurantArray
)从数据中填充,该数据来自webservice的响应.
数据mainRestaurantArray
如下: -
{
Address = "Ellisbridge Opposite Parimal Garden Near Doctor …
Run Code Online (Sandbox Code Playgroud)