我正在尝试分配标签,然后创建一个NSMutableArray
#import "myClass"
static NSString *kC = @"100";
static NSString *kLo = @"110";
@interface MyApp()
@property (strong, nonatomic) NSMutableArray *arrayTag;
@end
@Synthesize arrayTag;
在viewDidLoad
arrayTag = [[NSMutableArray alloc] init];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
cell.showsReorderControl = YES;
}
if (indexPath.row == 0)
{
cell.tag = kC;
NSString *cTag = [NSString stringWithFormat:@"%i", cell.tag];
if (![arrayTag containsObject:cTag])
{
[arrayTag addObject:cTag];
}
}
if (indexPath.row == 1)
{
cell.tag = kLo;
NSString *loTag = [NSString stringWithFormat:@"%i", cell.tag];
if (![arrayTag containsObject:loTag])
{
[arrayTag addObject:loTag];
}
}
return cell;
}
至NSLog
:
- (IBAction)doneButton:(id)sender
{
NSLog (@"Number of Objects in Array %i", arrayTag.count);
NSLog (@"Object at Index 0 in Array %@", [arrayTag objectAtIndex:0]);
NSLog (@"Object at Index 1 in Array %@", [arrayTag objectAtIndex:1]);
for (NSString *obj in arrayTag){
NSLog(@"From ArrayTag obj: %@", obj);
}
}
这是日志
2013-07-10 15:46:39.468 MyApp[1013:c07] Number of Objects in Array 2
2013-07-10 15:46:39.469 MyApp[1013:c07] Object at Index 0 in Array 1624272
2013-07-10 15:46:39.469 MyApp[1013:c07] Object at Index 1 in Array 1624256
2013-07-10 15:46:39.469 MyApp[1013:c07] From ArrayTag obj: 1624272
2013-07-10 15:46:39.470 MyApp[1013:c07] From ArrayTag obj: 1624256
Object[0] = 100
问: and的值不应该Object[1] = 110
匹配cell.tag
吗?为什么会显示 1624272 和 1624256?