I created a subclass that I want to use as a separate data model apart from the main viewController code. It contains some custom instance variables for the data - just NSIntegers - and a custom instance method to assign values to the variables. In my .h and .m subclass files I am also creating properties of the variables so that I can easily reference them.
I added this subclassed object as an instance variable to my viewController.
I then made it a property of the viewController and synthesized it as (nonatomic, retain).
Then in the viewDidLoad method of the viewController I call the instance method on the subclass to assign values to its variables.
My problem is that this method does not get run. I know this because I have 2 NSLog messages inside the method and they are not printing in the console.
Also I am referencing one of the subclass variables in a viewController method and its value remains initialized at 0.
The build succeeds with no errors and the app runs, but this one method is being ignored.
Here is what the code looks like...
the subclass .h and .m files
the viewController .h and .m code
It seems that it could not be any simpler, so why isn't the subclass's method being run?
I added this subclassed object as an instance variable to my viewController.
I then made it a property of the viewController and synthesized it as (nonatomic, retain).
Then in the viewDidLoad method of the viewController I call the instance method on the subclass to assign values to its variables.
My problem is that this method does not get run. I know this because I have 2 NSLog messages inside the method and they are not printing in the console.
Also I am referencing one of the subclass variables in a viewController method and its value remains initialized at 0.
The build succeeds with no errors and the app runs, but this one method is being ignored.
Here is what the code looks like...
the subclass .h and .m files
Code:
@interface payoutData : NSObject {
NSInteger ivar;
}
- (void) assignPayouts;
@property (nonatomic) NSInteger ivar;
@end
@implementation payoutData
@synthesize ivar;
- (void) assignPayouts {
ivar = 5;
NSLog(@"This message does not get printed\n");
}
@end
the viewController .h and .m code
Code:
@interface My_ViewController : UIViewController {
payoutData *paydata;
@property (nonatomic, retain) payoutData *paydata;
@end
@implementation My_SlotsViewController
@synthesize paydata;
- (void)viewDidLoad {
[paydata assignPayouts];
NSLog(@"the program makes it here because this message gets printed");
}
It seems that it could not be any simpler, so why isn't the subclass's method being run?