Objective c 使用iphone3g进行调试;它跳过cellForRowAtIndexPath
我有个奇怪的问题。我有一个代码可以在Xcode 3的iPhone模拟器上正常工作,但当我用iPhone 3G进行调试时,它跳过了部分代码 我有一个Objective c 使用iphone3g进行调试;它跳过cellForRowAtIndexPath,objective-c,uitableview,iphone-3g,Objective C,Uitableview,Iphone 3g,我有个奇怪的问题。我有一个代码可以在Xcode 3的iPhone模拟器上正常工作,但当我用iPhone 3G进行调试时,它跳过了部分代码 我有一个UITableView,它从服务器上的CSV获取数据(它可以读取我用日志测试过的文件),但表没有填充。所以我发现它完全跳过了cellforrowatinexpath:方法 代码如下: - (void)viewDidLoad { [super viewDidLoad]; //Inizializzo la posizione di
UITableView
,它从服务器上的CSV获取数据(它可以读取我用日志测试过的文件),但表没有填充。所以我发现它完全跳过了cellforrowatinexpath:
方法
代码如下:
- (void)viewDidLoad {
[super viewDidLoad];
//Inizializzo la posizione di partenza e calcolo distanza
CLLocation *startPos = [[CLLocation alloc]initWithLatitude:ST_LAT longitude:ST_LONG];
CLLocationDistance distanza = [posizione distanceFromLocation:startPos];
NSLog(@"Latitudine: %f",posizione.coordinate.latitude);
NSLog(@"Longitudine: %f",posizione.coordinate.longitude);
NSLog(@"Distanza (in metri): %f",distanza);
//Creo una lista temporaneamente non ordinata
NSMutableArray *listaNonOrdinata = [[NSMutableArray alloc]init];
//Prelevo dati da CSV e li inserisco in record
// NSString *fileString = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Lista1" ofType:@"csv"] encoding:NSUTF8StringEncoding error:nil];
NSString *fileString = [NSString stringWithContentsOfURL:[NSURL URLWithString:URL_CSV] encoding:NSUTF8StringEncoding error:nil];
NSLog(@"fileString: %@", fileString);
record = [fileString csvRows];
//Inserisco titolo
self.navigationItem.title = [[record objectAtIndex:0]objectAtIndex:C_TIPOLOGIA];
//Creo oggetto doppio per verificare se è presente più di una volta
id doppio = nil;
//Controllo tutto il record e inserisco nella listaNonOrdinata solo i dati singoli
//se il dato è doppio inserisco il rispettivo BOOL
for (int i=1; i < record.count; i++) {
//Carico un array temporaneo con tutti gli oggetti con chiave Item
NSMutableArray *temp = [[NSMutableArray alloc]init];
for (int j=0; j < listaNonOrdinata.count; j++) {
[temp addObject:[[listaNonOrdinata objectAtIndex:j]objectForKey:@"Item"]];
}
//Controllo che nessuno di questi sia già presente
doppio = [[record objectAtIndex:i] firstObjectCommonWithArray:temp];
[temp release];
//Inizializzo posizione oggetto
NSNumberFormatter *form = [[NSNumberFormatter alloc]init];
NSNumber *lat = [form numberFromString:[[record objectAtIndex:i]objectAtIndex:C_LAT]];
NSNumber *longit = [form numberFromString:[[record objectAtIndex:i]objectAtIndex:C_LONG]];
[form release];
CLLocation *posObj = [[CLLocation alloc]initWithLatitude:(CLLocationDegrees)[lat floatValue]
longitude:(CLLocationDegrees)[longit floatValue]];
//Se mi trovo nel raggio
if (distanza < RAGGIO) {
//Controllo che l'oggetto si trovi entro il raggio
if ([posObj distanceFromLocation:startPos] < RAGGIO) {
//Se non è doppio lo inserisco con Bool NO
if (doppio == nil) {
NSMutableDictionary *dizionario = [[NSMutableDictionary alloc]init];
[dizionario setObject:[[record objectAtIndex:i]objectAtIndex:C_TIPOLOGIA] forKey:@"Item"];
[dizionario setObject:[NSNumber numberWithBool:NO] forKey:@"Bool"];
[listaNonOrdinata addObject:dizionario];
[dizionario release];
} else {
//Cerco l'elemento doppio e gli sostituisco il Bool a YES
for (int j=0; j < listaNonOrdinata.count; j++) {
if ([[[listaNonOrdinata objectAtIndex:j]objectForKey:@"Item"] isEqualToString:[[record objectAtIndex:i]objectAtIndex:C_TIPOLOGIA]]) {
NSMutableDictionary *dizionario = [[NSMutableDictionary alloc]init];
[dizionario setObject:[[record objectAtIndex:i]objectAtIndex:C_TIPOLOGIA] forKey:@"Item"];
[dizionario setObject:[NSNumber numberWithBool:YES] forKey:@"Bool"];
[listaNonOrdinata replaceObjectAtIndex:j withObject:dizionario];
[dizionario release];
break;
}
}
}
}
} else {
//Controllo che l'oggetto si trovi fuori dal raggio
if ([posObj distanceFromLocation:startPos] > RAGGIO) {
//Se non è doppio lo inserisco con Bool NO
if (doppio == nil) {
NSMutableDictionary *dizionario = [[NSMutableDictionary alloc]init];
[dizionario setObject:[[record objectAtIndex:i]objectAtIndex:C_TIPOLOGIA] forKey:@"Item"];
[dizionario setObject:[NSNumber numberWithBool:NO] forKey:@"Bool"];
[listaNonOrdinata addObject:dizionario];
[dizionario release];
} else {
//Cerco l'elemento doppio e gli sostituisco il Bool a YES
for (int j=0; j < listaNonOrdinata.count; j++) {
if ([[[listaNonOrdinata objectAtIndex:j]objectForKey:@"Item"] isEqualToString:[[record objectAtIndex:i]objectAtIndex:C_TIPOLOGIA]]) {
NSMutableDictionary *dizionario = [[NSMutableDictionary alloc]init];
[dizionario setObject:[[record objectAtIndex:i]objectAtIndex:C_TIPOLOGIA] forKey:@"Item"];
[dizionario setObject:[NSNumber numberWithBool:YES] forKey:@"Bool"];
[listaNonOrdinata replaceObjectAtIndex:j withObject:dizionario];
[dizionario release];
break;
}
}
}
}
}
}
//Ordino listaNonOrdinata in ordine alfabetico
lista = [[NSArray alloc]init];
NSComparator comparatore = ^NSComparisonResult(id aDictionary, id anotherDictionary) {
return [[aDictionary objectForKey:@"Item"] localizedCaseInsensitiveCompare:[anotherDictionary objectForKey:@"Item"]];
};
lista = [listaNonOrdinata sortedArrayUsingComparator:comparatore];
[listaNonOrdinata release];
[startPos release];
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
//Retain:
[lista retain];
[record retain];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return lista.count;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
NSString *cellValue = [[lista objectAtIndex:indexPath.row]objectForKey:@"Item"];
cell.textLabel.text = cellValue;
NSLog(@"dettaglio bool Value: %@",[[[lista objectAtIndex:indexPath.row]objectForKey:@"Bool"]boolValue] ? @"YES" : @"NO");
if ([[[lista objectAtIndex:indexPath.row]objectForKey:@"Bool"]boolValue]) {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
[cellValue release];
return cell;
}
-(void)viewDidLoad{
[超级视图下载];
//帕坦扎和卡尔科洛地区的posizione酒店
CLLocation*startPos=[[CLLocation alloc]INITWITHLATIONE:ST_LAT经度:ST_LONG];
CLLocationDistanza=[posizione distanceFromLocation:startPos];
NSLog(@“纬度:%f”,位置坐标纬度);
NSLog(@“Longitudine:%f”,posizione.坐标.经度);
NSLog(@“Distanza(公制):%f”,Distanza);
//非有序的临时清单
NSMutableArray*listaNonOrdinata=[[NSMutableArray alloc]init];
//记录在案的初步数据
//NSString*fileString=[NSString STRINGWITH CONTENTS OFFILE:[[NSBundle mainBundle]pathForResource:@“csv”类型的“Lista1”编码:NSUTF8STRING编码错误:nil];
NSString*fileString=[NSString stringWithContentsOfURL:[NSURL URLWithString:URL\U CSV]编码:NSUTF8STRING编码错误:nil];
NSLog(@“fileString:%@”,fileString);
记录=[fileString csvRows];
//蒂托洛酒店
self.navigationItem.title=[[record objectAtIndex:0]objectAtIndex:C_TIPOLOGIA];
//在沃尔塔的一位医生的指导下,科罗·奥盖托·多皮奥(Creo oggetto doppio)
id doppio=nil;
//图托唱片公司总经理内拉·利斯塔诺·诺迪纳塔·索洛和达蒂·辛戈利
//我的拿督èdoppio inserisco和rispettivo BOOL
for(int i=1;iRAGGIO){
//这是一个很好的例子
如果(doppio==nil){
NSMUTABLEDDIctionary*DISIANIO=[[NSMUTABLEDIARY ALOC]init];
[dizionario setObject:[[record objectAtIndex:i]objectAtIndex:C_TIPOLOGIA]forKey:@“Item”];
[dizionario setObject:[NSNumber Number WithBool:NO]forKey:@“Bool”];
[Listanonnordinata addObject:dizionario];
[dizionario释放];
}否则{
//Cerco l'elemento doppio e gli sostituisco il Bool a是的
对于(int j=0;j