Reputation: 131
I want to load an image into my MAC OS desktop application. I have found plenty of documentation on how to do this on mobile iOS but how do I load the image on my desktop app since there is no UIImage(imageWithData).
NSData * imageData = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString:@"myurl"]];
productImage.image = [NSImage imageWithData:imageData];
Upvotes: 0
Views: 1371
Reputation: 386
imageWithData:
is a convenience initializer for initWithData:
in UIKIt. AppKit doesn't seem to have this, so you'll just need to use initWithData:
like this:
productImage.image = [[NSImage alloc] initWithData:imageData];
See this page for more info: https://developer.apple.com/reference/appkit/nsimage/1519941-initwithdata?language=objc
Upvotes: 5