沒有編譯器錯誤,但無法追蹤到我的類的實例方法。我很確定我只是沒有正確地設置它,但我想這可能是一些模糊的配置(希望不是)。我的自定義類在UIViewController中被破壞,無法追蹤到它,沒有編譯器錯誤
我對這些類的調用不能被追蹤到(只顯示彙編程序),ATLCalCellList類中的斷點(即init,load,clear)永遠不會執行。
的UIViewController頭:
// ATLCalendarViewController.h
#import <UIKit/UIKit.h>
#import "ATLCalCellList.h"
@interface ATLCalendarViewController : UIViewController {
ATLCalCellList* calCellList ;
}
@property (nonatomic, strong) ATLCalCellList* calCellList ;
- (IBAction)btnTestLoadListPress:(id)sender;
- (void) refreshCalCellList ;
@end
主文件:
// ATLCalendarViewController.m
#import "ATLCalendarViewController.h"
@implementation ATLCalendarViewController
@synthesize calCellList ;
- (void)viewDidLoad {
[super viewDidLoad];
// Custom initialization
[self.calCellList init] ;
}
- (IBAction)btnTestLoadListPress:(id)sender
{
[self refreshCalCellList] ;
}
- (void) refreshCalCellList
{
**//================================== PROBLEM ========================================**
// BREAKPOINTS ON THE 4 LINES BELOW GET CALLED, BUT CAN'T TRACE INTO THE METHOD CODE
// TRACE INTO ON ANY OF THESE SHOWS ASSEMBLER
// IT LOOKS LIKE THE CALLED CODE IN THE METHODS IS NOT BEING EXECUTED
[self.calCellList clear] ;
self.calCellList.calListCount = 0 ;
self.calCellList.calListDate = [NSDate date] ;
[self.calCellList load] ;
}
@end
爲calCellList類的頭文件是:
// ATLCalCellList.h
#import <Foundation/Foundation.h>
#import "ATLCalCellData.h"
@interface ATLCalCellList : NSObject {
NSMutableArray *calListArray ;
NSInteger calListCount ;
NSDate *calListDate ;
BOOL calListSimulate ;
}
// PROPERTIES
@ property(nonatomic, strong) NSMutableArray *calListArray ;
@ property(nonatomic) NSInteger calListCount ;
@ property(nonatomic, strong) NSDate *calListDate ;
@ property(nonatomic) BOOL calListSimulate ;
// METHODS
- (id) init ;
- (BOOL) load ;
- (BOOL) save ;
- (void) clear ;
- (void) addCell: (ATLCalCellData *) calCellData ;
- (void) removeCell: (ATLCalCellData *) calCellData ;
如果你需要看到完整的類實現,這裏的大部分是:
// ATLCalCellList.m
#import "ATLCalCellList.h"
@implementation ATLCalCellList
@synthesize calListArray ;
@synthesize calListCount ;
@synthesize calListDate ;
@synthesize calListSimulate ;
- (id) init
{
self = [super init] ;
self.calListArray = nil ;
self.calListArray = [calListArray init] ;
self.calListDate = [NSDate date] ;
return self ;
}
- (BOOL) load
{
// load data for one day
ATLCalCellData* newCell ;
if ([newCell init]) {
newCell.calCellDate = self.calListDate ;
newCell.calCellHour = x ;
newCell.calCellMinute = 0 ;
newCell.calCellTitle = @"Appt with Destiny" ;
newCell.calCellLocation = @"Atlas World HQ" ;
[newCell.calCellAlliesIDList addObject: @"333000333" ] ;
[newCell.calCellAlliesNameList addObject: @"Joe Chicago"] ;
newCell.calCellDurationMinutes = 60 ;
newCell.calCellAlarm1AdvanceMinutes = 30 ;
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];
[offsetComponents setHour:0];
[offsetComponents setMinute: newCell.calCellAlarm1AdvanceMinutes];
newCell.calCellAlarm1Datetime =
[gregorian dateByAddingComponents:offsetComponents toDate:
newCell.calCellAlarm1Datetime options:0];
}
}
}
}
} else {
// load the cells from the actual database:
// #OPENTASK
// end
}
return TRUE ;
}
- (BOOL) save
{
// save data for one day
return TRUE ;
}
- (void) clear {
// Clear the daylist array
self.calListArray = nil ;
[self.calListArray init];
}
- (void) addCell: (ATLCalCellData *) calendarCell {
[self.calListArray addObject: calendarCell];
}
- (void) removeCell: (ATLCalCellData *) calendarCell {
// Find and remove the passed in cell from the array:
// #TBD Locate the cell with the datetime and userid, then delete it
//
}
@end
感謝信AROTH ...這奏效了,有時候你看不出它在自己的代碼......在一定程度上,我知道的是,類應該初始化實例,但我不知何故認爲ARC意味着不再有ALLOC。我查看了這個以及看到ARC只是自動處理釋放代碼,但你仍然應該做的分配。 無論如何,我完全按照您的指示進行了更改。我放棄了無關的變量聲明。 (我曾經想過SYNTHESIZE只創建SETters。)真的很感激你的快速反應,帶來一些不必要的編碼苦難到底! – 2012-03-05 07:26:38