No compiler errors, but can’t trace into instance methods of my classes. I’m pretty sure I’m just not setting this up correctly, but I guess it could be some obscure configuration (hope not).
My calls to the classes can’t be traced into (just shows assembler), and breakpoints in the ATLCalCellList class (ie, at init, load, clear) never execute.
UIViewController header:
// 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
Main file:
// 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
The class header file for calCellList is:
// 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 ;
In case you need to see the full class implementation, here’s most of it:
// 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
I believe the problem is that you’re calling
initon something that hasn’t actually been allocated yet. Essentially your code is telling the application to go to whatever random place in memory thatself.calCellListhappens to point to, treat it as an object, and send aninitmessage to it. This may, of course, cause all sorts of issues.It may work better if you do:
Also note that if you do:
…then you don’t need to also declare a backing ivar for the field. Specifically, this is redundant:
When you
@synthesizethe property, a backing ivar of the same name will automatically be generated for you. The code you have is essentially declaring the ivar twice, which is harmless but unnecessary.Edit: Just took a closer look at your code, and you seem to be making the same mistake in other places as well:
As above, this will not work. You can’t initialize an unassigned variable by calling
initon it. You need toallocan instance, and then calliniton that instance. Like: