我的問題是我有一個NSMutableArray
與latLongArray
包含對象的名稱,如果數組數大於4我如何獲得數組的每個第四個元素?
我要添加每4個對象與名稱elementArray另一個數組,如果小於4要添加elementArray中的所有對象,並打印NSLog中的所有數據。
任何機構都可以幫助我解決這個問題。 這裏是我的代碼
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
NSString *cellText = selectedCell.textLabel.text;
placeDC *placedc;
placedc = [dataArray objectAtIndex:[indexPath row]];
if ([txtFrom isFirstResponder]) {
txtFrom.text=cellText;
NSLog(@"%@",cellText);
originlat=placedc.latitude;
originlng=placedc.longitude;
NSLog(@"%@",placedc.countryFullName);
}
else
{
txtTo.text=cellText;
destinationLat=placedc.latitude;
DestinationLng=placedc.longitude;
DBHandler *db=[[DBHandler alloc]init];
NSLog(@"%@",placedc.countryFullName);
latLongArray=[db googlePlaces:originlat :originlng :destinationLat :DestinationLng];
if ([latLongArray count]>4) {
for (int i =0; i<=[latLongArray count]; i=i+4) {
}
NSLog(@"%d",[elentArray count]);
}
}
myTableView.hidden=YES;
[self.view endEditing:YES];
}
不工作元素數組0 0 – Saleem