StigPing
StigPing

Reputation: 195

'SKView?' does not have a member named 'bounds'

I have recently come up to an error with a code and want to fix this. It is swift coded and I hope you guys are able to help me with this.

The error says: 'SKView?' does not have a member named 'bounds'

If you could help me with this as this is my first swift app, I would love you forever :)

Here are the code for the "title" of this question.

overlay = SKSpriteNode(color: UIColor.grayColor(), size: self.view.bounds.size)

Upvotes: 2

Views: 651

Answers (1)

Brian Tracy
Brian Tracy

Reputation: 6831

SKView? does not have a property of type bounds (note the ?), but SKView! might.

In the first example, and the one you are getting an error on, you are not implicitly unwrapping the optional. To do this, use the ! operator.

self.view!.bounds.size will yield the correct type. Note the use of the ! operator to unwrap the optional.

Edit: You have many of the same errors here. The tipoff is in the error message. Anything along the lines of <x> does not have member named <y> is a similar error.

Upvotes: 3

Related Questions