Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-1826] CGGradient initializer imported incorrectly into Swift 3 #44435

Closed
swift-ci opened this issue Jun 19, 2016 · 1 comment
Closed

[SR-1826] CGGradient initializer imported incorrectly into Swift 3 #44435

swift-ci opened this issue Jun 19, 2016 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. SDKOverlay

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-1826
Radar rdar://problem/26883643
Original Reporter scelis (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode Version 8.0 beta (8S128d)

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug, SDKOverlay
Assignee None
Priority Medium

md5: c94429680602a936e55b543293f9f2b4

Issue Description:

In Swift 2.2, we had:

func CGGradientCreateWithColors(
    _ space: CGColorSpace?,
    _ colors: CFArray?,
    _ locations: UnsafePointer<CGFloat>)
    -> CGGradient?

In Swift 3 this has changed to:

CGGradient.init?(
    colorsSpace: CGColorSpace,
    colors: CFArray,
    locations: UnsafePointer<CGFloat>)

The documentation for the locations parameter states that locations may be either:

  1. NULL

  2. An array of CGFloats with the same number of elements as the colors array

This new Swift 3 initializer does not accept `nil` for locations, which it probably should. In which case taking a type of `UnsafePointer<CGFloat>?` would be better. However, wouldn't an `UnsafeBufferPointer<CGFloat>?` be preferred? Although ideally it would accept `[CGFloat]?` and avoid unsafe pointers altogether.

@swift-ci
Copy link
Collaborator Author

Comment by Sebastian Celis (JIRA)

Looks like this has been addressed in Swift 3.1. locations is now an optional parameter.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. SDKOverlay
Projects
None yet
Development

No branches or pull requests

1 participant