0
越來越對象我的UITableViewController的子類,我初始化子類與其他自定義類的NSMutableArray中:獲得EXC_BAD_ACCESS中的UITableViewController而從NSMutableArray的
#import <UIKit/UIKit.h>
#import "NUBCheckpointModel.h"
@interface NUBUserCheckpointModel : NSObject
@property (nonatomic,assign) NSString* objId;
@property (nonatomic,assign) NSString* userId;
@property (nonatomic,assign) NSString* checkpointId;
@property (nonatomic,assign) NSDate* dateAdded;
@property (nonatomic,assign) NUBCheckpointModel* checkpoint;
+ (NUBUserCheckpointModel*) fromJson: (NSString*)json;
@end
從另一個視圖控制器生成此陣,被傳遞這個子類TableViewController,其中包含此屬性
@property (nonatomic,retain) NSMutableArray* userCheckpointData;
此屬性設置是這樣的:
- (id)initWithFrame: (CGRect)frame withType: (TableType)typeOfTable fromParent: (UIViewController*)parent data: (NSMutableArray*)ucpData
{
self = [self init];
if (self) {
self.tableView = [[UITableView alloc] initWithFrame:frame];
self.parentController = parent;
self.userCheckpointData = ucpData;
[self styleTable];
[self addPullToRefreshHeader];
typeCategory = typeOfTable;
}
return self;
}
一切都很好,直到這部分,任何操作,包括試圖從數組中獲取對象工作正常。我測試了它。
我用來測試數組的代碼是:
NUBUserCheckpointModel* model = [self.userCheckpointData objectAtIndex:0];
NSLog(model.objId);
然而,這非常相同的代碼,在這裏當用於
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
給我EXC_BAD_ACCESS。我可以知道這是爲什麼發生嗎?我似乎無法弄清楚爲什麼。我使用ARC btw。謝謝。
偉大的答案,謝謝! – nubela 2012-03-21 12:16:23