Unexpected nil value when initializing custom NSViewController in Objective-C
I've tried everything I can think of but I've been struggling with this for a few days now and could really use some help... I'm experimenting with I'm relatively new to this, so bear with me... I'm working with an scenario where my custom `NSViewController` is unexpectedly receiving a `nil` value for one of its properties during initialization. I have a custom initializer that takes a parameter for a data model but when I instantiate the controller, it seems to be `nil` at runtime. Hereβs my custom view controller: ```objective-c @interface MyCustomViewController : NSViewController @property (nonatomic, strong) MyDataModel *dataModel; - (instancetype)initWithDataModel:(MyDataModel *)dataModel; @end @implementation MyCustomViewController - (instancetype)initWithDataModel:(MyDataModel *)dataModel { self = [super initWithNibName:nil bundle:nil]; if (self) { _dataModel = dataModel; } return self; } @end ``` When I try to instantiate `MyCustomViewController` from another controller, I do it like this: ```objective-c MyDataModel *model = [[MyDataModel alloc] init]; MyCustomViewController *vc = [[MyCustomViewController alloc] initWithDataModel:model]; [self presentViewControllerAsModal:vc]; ``` However, when I check `vc.dataModel` later, it ends up being `nil`. Iβve also made sure that `model` is not `nil` before passing it to the view controller. I've tried debugging by adding logs in the initializer, and they confirm that the initializer is called, but somehow the property is not set as expected. I've verified that `MyDataModel` is properly initialized, and I don't have any issues with memory management as I'm using ARC. I even tried creating `MyDataModel` with a different initialization method, to rule out any issues there. Can someone guide to figure out why `dataModel` is `nil` after instantiation? Is there something specific to NSViewController instantiation that I might be missing? I'm using Xcode 14.3 and targeting macOS 13.0. I'd really appreciate any guidance on this. The stack includes Objective-C and several other technologies. Thanks, I really appreciate it! Any advice would be much appreciated. I've been using Objective-C for about a year now.