0
不知道我要出错的地方。我有一个最多包含3个对象的数组。我想检查是否有任何数组对象继续使用0,&,如果是,则将它们格式化为NSString
。如果没有,我想包括在索引0的对象。想要检查一个数组是否包含全部或只包含某些对象 - iOS
在正确的方向一个点将是伟大的!
// add annotation
MKPointAnnotation *point = [MKPointAnnotation new];
point.coordinate = (CLLocationCoordinate2D){[self.eventPlan.location_lat doubleValue], [self.eventPlan.location_lng doubleValue]};
NSArray *locationA = [self.eventPlan.location_address componentsSeparatedByString:@", "];
point.title = locationA[0];
if ([locationA containsObject:locationA[1]]) {
point.subtitle = [NSString stringWithFormat:@"%@, %@", locationA[1], locationA[2]];
} else {
point.subtitle = [NSString stringWithFormat:@"%@", locationA[1]];
}
[mapView addAnnotation:point];
更新:有没有一种方法来检查我的数组没有延伸超过索引[0]? –
locationA.count会告诉你有多少物体,是你问的? – rdelmar