InjectionIII: found objects does not initialize
Hi, found a case that some object does not initialize as expect. The demo code is below.
- change the DemoViewController code to trigger recompile the DemoViewController
- reenter DemoViewController, found the label is null, but the contentLabel is OK
@interface DemoViewController ()
@property (nonatomic, strong) UILabel *contentLabel;
@end
@implementation DemoViewController
- (void)viewDidLoad {
[super viewDidLoad];
UILabel *label = [[UILabel alloc] init];
label.frame = CGRectMake(0, 200, 100, 100);
label.backgroundColor = [UIColor whiteColor];
label.text = @"label";
NSLog(@"label = %@", label); // label is null, not initialize
[self.view addSubview:label];
[self.view addSubview:self.contentLabel];
NSLog(@"label = %@", self.contentLabel); // contentLabel is null, not initialize
}
- (UILabel *)contentLabel {
if (!_contentLabel) {
_contentLabel = [UILabel new];
_contentLabel.frame = CGRectMake(100, 100, 100, 100);
_contentLabel.backgroundColor = [UIColor whiteColor];
_contentLabel.text = @"123";
}
return _contentLabel;
}
@end
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 20 (13 by maintainers)
So, after the embarrassment of yesterday it’s easy enough to switch back to using dlopen() for device injection. I’ve updated the HotReloading project to remove
InjectionScratchand uploaded a new release candidate of theInjectionIII.appif you want to give it/them a try together. Thanks so much for letting me know this was a possibility again; On-device injection is back open for business. If you notice anything broken let me know!Seriously? You seem to be right! SO, this has all been a colossal waste of time then?