Reputation: 524
Sorry I have been away from programming for a while (since before Swift 3) and even back then I wasn't real good at it. Anyway I was playing around with SwiftyCam:
https://github.com/Awalz/SwiftyCam
And I notice these squares in the code. Anyone know what these things are? Never saw this before, and not sure if it's new with Swift 3 or if I just haven't come across them. Example:
func swiftyCam(_ swiftyCam: SwiftyCamViewController, didFocusAtPoint point: CGPoint) {
let focusView = UIImageView(image: #imageLiteral(resourceName: "focus"))
focusView.center = point
focusView.alpha = 0.0
view.addSubview(focusView)
}
Okay well I can't even paste it. It's before the word "focus" and there are no quotations it's just (resourceName: ***insert square here***focus)
I hope this makes sense and sorry if it's a dumb question I just don't know how to look something like this up because you can't type squares int he docs or anything.
Upvotes: 0
Views: 306
Reputation: 271175
The little squares are actually text. They just appear in Xcode as little squares with the name of the image after it. e.g.
As you can see in your pasted code, it's just this in text form:
#imageLiteral(resourceName: "focus")
The above is basically equivalent to:
UIImage(named: "focus")
Another one of these cool literals is #colorLiteral
. e.g.
#colorLiteral(red: 0.4131736755, green: 0.7676505446, blue: 0.4273042679, alpha: 1)
These literals are just syntactic sugar that makes your code look prettier:
Upvotes: 3