【发布时间】:2011-09-21 22:30:16
【问题描述】:
我在一个类中有一个 NSMutableDictionary
@interface ClassName : UITableViewController {
NSMutableArray *doctors_set;
}
@property (nonatomic, retain) NSMutableArray *doctors_set;
@implementation ClassName
@synthesize DocID,doctors_set;
我正在添加 4 个对象
DoctorsSet *set = [[DoctorsSet alloc] init];
//DoctorsSet is an extended NSObject
[doctors_set addObject:set];
我想要的是使用同一类中的集合(我正在使用 tableview) 所以当我点击单元格时,我必须恢复所点击索引上的集合
DoctorsSet *set = (DoctorsSet *)[doctors_set objectAtIndex:indexPath.row];
当发生 didSelectRowAtIndexPath 事件时。索引处的集合丢失,我可以在调试器中看到它。索引甚至没有 DoctorsSet 类型..它们被一些随机类型替换,告诉我以某种方式没有保留对象...... 如果我在表格单元格上点击 2.3 次,就会发生这种情况
当我在调试器中分配数组时,我得到
self
doctors_set = (_NSARRAYM *) pointerid 4 objects
0 = (DoctorsSet *) pointerid
1 = (DoctorsSet *) pointerid
2 = (DoctorsSet *) pointerid
3 = (DoctorsSet *) pointerid
当我得到错误时,因为它说选择器不属于对象(那是因为对象本身丢失了)
self
doctors_set = (_NSARRAYM *) pointerid 4 objects
0 = (NSObject *) pointerid
1 = (NSObject *) pointerid
2 = (NSCFString *) pointerid
3 = (UITouchData *) pointerid
【问题讨论】:
-
你能把你初始化
doctors_set的sn-p贴出来吗? -
是的,当我从数据库中读取每个医生时,我正在做一段时间...请参阅我对答案 1 的评论,我已将代码粘贴在那里。我可以不要在 cmets 上更好地格式化它......
标签: iphone xcode pointers nsmutablearray retain