私はセクション化されたテーブルビューの概念を実装していて、特定のポイントで打たれました。次のような2つのオブジェクトを持つNSMutableArrayがあります。
<__NSArrayI 0xabf8c00>(
{
City = "SanFransisco ";
Latitude = "28.602704";
Longitude = "-81.430760";
State = California;
},
{
City = Orlando;
Latitude = "28.49379";
Longitude = "-81.474251";
State = Florida;
},
)
,
<__NSCFArray 0xab38ec0>(
{
geometry = {
location = {
lat = "37.789632";
lng = "-122.417004";
};
};
name = "St. Francis Memorial Hospital";
vicinity = "900 Hyde Street, San Francisco";
},
{
geometry = {
location = {
lat = "37.794363";
lng = "-122.395784";
};
};
name = "St Memorial Hospital";
vicinity = "5 Embarcadero Center, San Francisco";
},
{
geometry = {
location = {
lat = "37.788297";
lng = "-122.409653";
};
};
name = "Global Memorial Hospital";
vicinity = "490 Post Street #520, San Francisco";
},
)
これらの2つのオブジェクトをtableViewの2つのセクションにロードしています。しかし、最初のオブジェクトの各キー(都市、緯度、経度)と2番目のオブジェクトの緯度、緯度、近くのNSMutableDictionaryを比較して取り込む方法を取得できませんでした。私はこのようにしましたが、エラーが発生します:**SIGABRT error**
編集 :
- (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];
cell.accessoryType= UITableViewCellAccessoryDetailDisclosureButton;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
NSMutableArray *array = [listOfItems objectAtIndex:indexPath.section];
int section=indexPath.section;
if(section==0)
{
for (int i=0;i<[array count];i++)
{
cell.textLabel.text = [[array objectAtIndex:i] objectForKey:@"City"] ;
cell.textLabel.tag=3;
cell.textLabel.font=[UIFont boldSystemFontOfSize:12];
NSString *lat=[NSString stringWithFormat:@"%@",[[array objectAtIndex:i] objectForKey:@"Latitude"]];
UILabel *latitude = [[UILabel alloc]initWithFrame:CGRectMake(10, 50, 320, 10)];
latitude .font=[UIFont fontWithName:@"TimesNewRomanPS-BoldMT" size:12];
[latitude setTextAlignment:UITextAlignmentLeft];
latitude.text=[NSString stringWithFormat:@"%@",lat];
latitude.tag=1;
[cell addSubview:latitude ];
latitude.hidden=YES;
[latitude release];
NSString *lng=[NSString stringWithFormat:@"%@",[[array objectAtIndex:i] objectForKey:@"Longitude"]];
UILabel *longitude = [[UILabel alloc]initWithFrame:CGRectMake(10, 80, 320, 10)];
longitude .font=[UIFont fontWithName:@"TimesNewRomanPS-BoldMT" size:12];
[longitude setTextAlignment:UITextAlignmentLeft];
longitude.text=[NSString stringWithFormat:@"%@",lng];
longitude.tag=2;
[cell addSubview:longitude ];
longitude.hidden=YES;
[longitude release];
return cell;
}
}
if(section==1)
{
for (int i=0;i<[array count];i++)
{
cell.textLabel.text =[[array objectAtIndex:i] objectForKey:@"name"] ;
cell.textLabel.lineBreakMode=UILineBreakModeWordWrap;
cell.textLabel.numberOfLines=0;
cell.textLabel.font=[UIFont boldSystemFontOfSize:12];
cell.textLabel.tag=3;
NSMutableDictionary * location = [[[array objectAtIndex:indexPath.row]objectForKey:@"geometry"]objectForKey:@"location"];
NSString * lat = [location objectForKey:@"lat"];
NSString * lng = [location objectForKey:@"lng"];
UILabel *latitude = [[UILabel alloc]initWithFrame:CGRectMake(10, 80, 320, 10)];
latitude .font=[UIFont fontWithName:@"TimesNewRomanPS-BoldMT" size:12];
[latitude setTextAlignment:UITextAlignmentLeft];
latitude.text=[NSString stringWithFormat:@"%@",lat];
latitude.tag=1;
[cell addSubview:latitude ];
latitude.hidden=YES;
[latitude release];
UILabel *longitude = [[UILabel alloc]initWithFrame:CGRectMake(10, 85, 320, 10)];
longitude .font=[UIFont fontWithName:@"TimesNewRomanPS-BoldMT" size:12];
[longitude setTextAlignment:UITextAlignmentLeft];
[longitude setText:[NSString stringWithFormat:@"%@",lng]];
longitude.tag=2;
[cell addSubview:longitude ];
longitude.hidden=YES;
[longitude release];
NSString *vicinity1 = [[array objectAtIndex:indexPath.row]objectForKey:@"vicinity"];
UILabel *vicinity = [[UILabel alloc]initWithFrame:CGRectMake(10, 45, 320, 10)];
vicinity .font=[UIFont fontWithName:@"TimesNewRomanPS-BoldMT" size:12];
[vicinity setTextAlignment:UITextAlignmentLeft];
vicinity.text=[NSString stringWithFormat:@"%@",vicinity1];
vicinity.tag=4;
[cell addSubview:vicinity ];
vicinity.hidden=YES;
[vicinity release];
return cell;
}
}
}
今回はどこがおかしいの?