Robby
Robby

Reputation: 21

why Nil is not compatible with expected argument type 'UnsafePointer<CGAffineTransform>' in swift 4?

I'm trying to create a CGMutablePath() such as:

let path = CGMutablePath()
CGPathAddRect(path, nil, playableRect)

The compiler keeps on giving me the following error:

Nil is not compatible with expected argument type 'UnsafePointer'

I can't seem to find any info on this matter online. I've tried converting the Int to CGFloat but it doesn't seem to make a difference.

Upvotes: 1

Views: 1113

Answers (1)

matt
matt

Reputation: 536027

A major problem with your code is that CGPathAddRect is not valid in any recent version of Swift. You should update your Xcode to something like Xcode 9.2 and write your code in a modern Swift like Swift 4.

You will then be able to write:

let path = CGMutablePath()
path.addRect(playableRect)

...and things will be much simpler and clearer for you.

Upvotes: 4

Related Questions