我有一个这样的元素数组
150, 150, 150, 571, 571, 571, 692, 692, 692, 123, 123, 123, 144, 144, 144, 147, 147, 147, 155, 155, 155, 542, 542, 542, 548, 548、548、551、551、551
我曾经在 tableviewcell 中显示我的数组元素,在那里我使用了这样的代码
NSArray *array=[jsonarray valueForKey:@"ID"];
mySet = [NSSet setWithArray:array] ;
NSLog(@"%@",mySet);
现在我得到了我的所有元素,这些元素在 myset 中没有重复为 11 个元素,但是如果我打印 myset 值,我会得到这样的
2012-08-01 12:49:53.049 jothi R&D[3647:f803] {( 551, 548, 692, 150, 155, 147, 542, 571, 123, 144)} 2012-08-01 12:49:53.050 jothi R&D[3647:f803] {( 551, 548, 692, 150, 155, 147, 542, 571, 123, 144 )} 2012-08-01 12:49:53.050 jothi R&D[3647:f803] {( 551 , 548, 692, 150, 155, 147, 542, 571, 123, 144)} 2012-08-01 12:49:53.051 jothi R&D[3647:f803] {( 551, 548, 692, 150, 155, 147 , 542, 571, 123, 144 )} 2012-08-01 12:49:53.051 jothi R&D[3647:f803] {( 551, 548, 692, 150, 155, 147, 542, 571, 123, 144 )} 2012-08-01 12:49:53.052 jothi R&D[3647:f803] {( 551, 548, 692, 150, 155, 147, 542, 571, 123,144)} 2012-08-01 12:49:53.052 jothi R&D[3647:f803] {(551, 548, 692, 150, 155, 147, 542, 571, 123, 144)} 2012-08-01 12: 49:53.053 jothi R&D[3647:f803] {( 551, 548, 692, 150, 155, 147, 542, 571, 123, 144 )} 2012-08-01 12:49:53.053 jothi R&D[3647:f803] {(551, 548, 692, 150, 155, 147, 542, 571, 123, 144)} 2012-08-01 12:49:53.054 jothi R&D[3647:f803] {( 551, 548, 692, 150, 155, 147, 542, 571, 123, 144)} 2012-08-01 12:49:53.054 jothi R&D[3647:f803] {( 551, 548, 692, 150, 155, 147, 542, 571, 123, 144)}123, 144)} 2012-08-01 12:49:53.053 jothi R&D[3647:f803] {(551, 548, 692, 150, 155, 147, 542, 571, 123, 144)} 2012-08-01 12:49:53.053 jothi R&D[3647:f803] {( 551, 548, 692, 150, 155, 147, 542, 571, 123, 144)} 2012-08-01 12:49:53.054 jothi R&D[3647: f803] {( 551, 548, 692, 150, 155, 147, 542, 571, 123, 144 )} 2012-08-01 12:49:53.054 jothi R&D[3647:f803] {( 551, 548, 692, 150, 155, 147, 542, 571, 123, 144)}123, 144)} 2012-08-01 12:49:53.053 jothi R&D[3647:f803] {(551, 548, 692, 150, 155, 147, 542, 571, 123, 144)} 2012-08-01 12:49:53.053 jothi R&D[3647:f803] {( 551, 548, 692, 150, 155, 147, 542, 571, 123, 144)} 2012-08-01 12:49:53.054 jothi R&D[3647: f803] {( 551, 548, 692, 150, 155, 147, 542, 571, 123, 144 )} 2012-08-01 12:49:53.054 jothi R&D[3647:f803] {( 551, 548, 692, 150, 155, 147, 542, 571, 123, 144)}147, 542, 571, 123, 144)} 2012-08-01 12:49:53.054 jothi R&D[3647:f803] {(551, 548, 692, 150, 155, 147, 542, 571, 123, 144) } 2012-08-01 12:49:53.054 jothi R&D[3647:f803] {( 551, 548, 692, 150, 155, 147, 542, 571, 123, 144 )}147, 542, 571, 123, 144)} 2012-08-01 12:49:53.054 jothi R&D[3647:f803] {(551, 548, 692, 150, 155, 147, 542, 571, 123, 144) } 2012-08-01 12:49:53.054 jothi R&D[3647:f803] {( 551, 548, 692, 150, 155, 147, 542, 571, 123, 144 )}
如果我试图在 UItableviewcell 中打印它,我在 return[myset count]; 时遇到了 BAD ACCESS 问题。我的表格视图单元格包含
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [myset count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
{ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
cell.textLabel.text=[myset objectAtIndex:indexPath.row];
return cell;
}
这里 jsonarray 是 NSMutableArray,myset 是 NSSet ..请指导..