2013-07-10 3 views
0

내가 태그를 할당하려고 한 다음 NSMutableArray있는 NSMutableArray NSLog는 다른 결과

#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에 만드는거야 출력

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 

Q : Object[0] = 100Object[1] = 110의 값이 cell.tag과 일치하지 않아야합니까? 왜 1624272와 1624256이 표시됩니까?

답변

3

의 UIView의 tag 속성은이 NSString를 할당하는, 또는 더 정확하게하기 위해, NSInteger 기대하고, 태그에 NSString의 메모리 주소입니다. 이 같은

사용 무언가 :

static NSInteger kC = 100; 
static NSInteger kLo = 110; 
+0

나는 내가하고 있던 바보 같은 것을 알고 있었다! 감사. – user1107173