Loading/Downloading image from URL on Swift

前端 未结 30 2510
感动是毒
感动是毒 2020-11-21 05:39

I\'d like to load an image from a URL in my application, so I first tried with Objective-C and it worked, however, with Swift, I\'ve a compilation error:

30条回答
  •  无人及你
    2020-11-21 06:03

    You’ll want to do:

    UIImage(data: data)
    

    In Swift, they’ve replaced most Objective C factory methods with regular constructors.

    See:

    https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithObjective-CAPIs.html#//apple_ref/doc/uid/TP40014216-CH4-XID_26

提交回复
热议问题