When I load a webp image in Image.xcassets folder, the code is as follows:
- (UIImageView *)topImageView{
if (!_topImageView) {
_topImageView = [[UIImageView alloc] init];
NSBundle *bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"DICarpoolRes" ofType:@"bundle"]];
NSString *path = [bundle pathForResource:@"bts_coupons_head_ic" ofType:@"webp"];
UIImage *image = [UIImage sd_imageWithWebPData:[NSData dataWithContentsOfFile:path]];
_topImageView.image = image;
}
return _topImageView;
}
Then, console says that path is nil, also image is nil. as follows:
Printing description of bundle:NSBundle </Users/didi/Library/Developer/CoreSimulator/Devices/A0A8CD0A-901B-443D-9DBF-2B6934ED26BE/data/Containers/Bundle/Application/C0D98241-ADE1-4EE0-86D1-D3917DA49899/OneTravel.app/DICarpoolRes.bundle> (not yet loaded)
Printing description of path:
<nil>
Printing description of image:
<nil>
Why bundle is not yet load? Thank you for your answer.