内存位置分配问题

时间:2011-07-17 18:32:45

标签: iphone objective-c ipad memory-management three20

我正在使用UITableViewController,我有一个在识别手势时调用的函数(向右/向左滑动等)。我也在实现自定义单元类。 在刷卡功能中我有:

 CustomCell* cell = (CustomCell *) [self.tableView cellForRowAtIndexPath:indexPath];
  ((RKMappableObjectTableItem *)[cell object]).options = YES;

每个单元格都有一个关联的对象,它是一个RKMappableObjectTableItem,它有两个属性,一个是对象,一个是BOOL。

@interface RKMappableObjectTableItem : TTTableLinkedItem {
    NSObject* _object;
    BOOL _options;
}

@property (nonatomic, retain) NSObject* object;
@property (nonatomic, assign) BOOL options;

+ (id)itemWithObject:(NSObject*)object;

@end

现在我在这个滑动功能中尝试做的是将选项bool设置为YES。 执行此滑动功能后,我的rowHeightForObject

+ (CGFloat)tableView:(UITableView *)tableView rowHeightForObject:(id)item {
  if (((RKMappableObjectTableItem *) item).options){
        NSLog(@"OPTIONS HEIGHT SET");
    }
}

被执行,这个rowHeightForObject位于我的CustomClass实现中。这里的项目是RKMappableObjectTableItem。从理论上讲,我在这里获得的项目的内存地址应该与我从刷卡功能获得的内容相同吗?但在使用调试器后,我检查了它的不同,因此if语句永远不会执行。 问题是为什么这个以及如何解决它?

更新

以下是RKMappableObjectTableItem的实现

@implementation RKMappableObjectTableItem

@synthesize object = _object;
@synthesize options = _options;

+ (id)itemWithObject:(NSObject*)object {
    RKMappableObjectTableItem* tableItem = [self new];
    tableItem.URL = [object URLValueWithName:@"show"];
    tableItem.object = object;
    return [tableItem autorelease];
}

@end

0 个答案:

没有答案
相关问题