cannot convert value of type UIImage to expected argument type string
13,483
Solution 1
Maybe I'm missing something but why are you adding this?
#imageLiteral(resourceName:
The correct syntax is
let ground = SKSpriteNode(imageNamed: "Ground")
Solution 2
I was doing :
profileImgView.image = UIImage(named: #imageLiteral(resourceName: "default_UserImage"))
while it should be :
profileImgView.image = #imageLiteral(resourceName: "default_UserImage")
imageLiteral already return UIImage.
Related videos on Youtube
Author by
Gh0st
Updated on June 04, 2022Comments
-
Gh0st almost 2 years
I have some problem with swift.
Ground = SKSpriteNode(imageNamed: "#imageLiteral(resourceName: "Ground")")
Here it says "cannot convert value of type UIImage to expected argument type string" how can i fix this
-
Gh0st almost 8 yearsI'm trying to get the "Ground" picture on the bottom of the screen when i do 'let' or 'string' it tells me to add a
;
and no matter how many i type it always wants one more. That code is insideoverride func didMove(to view: SKView)
and i got avar Ground = SKSpriteNode()
insideclass GameScene: SKScene {
All i did was start a Game project in Xcode and i only wrote that so far. -
Gh0st almost 8 yearsSo i was selecting the img when i used that line of code i copied yours next to mine and the only difference was that yours wasn't selecting any img thank you fixed the problem