• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Why are some Core Graphics APIs "hidden" from Swift?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why are some Core Graphics APIs "hidden" from Swift?


  • Subject: Re: Why are some Core Graphics APIs "hidden" from Swift?
  • From: Quincey Morris <email@hidden>
  • Date: Wed, 30 Aug 2017 15:42:42 -0700

On Aug 30, 2017, at 14:04 , Rick Mann <email@hidden> wrote:
>
> But the X, Y versions have a double underscore:
>
>    CGContext.__addArc(x1: CGFloat, y1: CGFloat, x2: CGFloat, y2: CGFloat,
> radius: CGFloat)
>
> Why is this?

I believe the double-underscore prefix indicates an Obj-C API that is exposed
through Swift but not intended for general use. It may be that it’s there for
3rd party developers who insist on using that particular API, or it may be for
the Swift compiler to call through to. There is generally a better (simpler)
API that does the same thing.

In this case, it may be that the x/y plus 1/2 coordinate pattern is an outlier,
and Swift standardizes on points instead, in geometrical methods. You can pass
CGPoint(x: x1, y:y1) and CGPoint (x: x2, y: y2) into the other API. My guess is
that Swift generates the exact same code for the parameters in either case,
because it can *always* inline the CGPoint creation methods. You’re not paying
a performance or code size penalty, and you are gaining consistency.

I don’t know if my reasoning is correct, but it’s an argument that can be made
in other similar cases too, so I think it’s something like that.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Why are some Core Graphics APIs "hidden" from Swift? (From: Rick Mann <email@hidden>)

  • Prev by Date: Why are some Core Graphics APIs "hidden" from Swift?
  • Previous by thread: Why are some Core Graphics APIs "hidden" from Swift?
  • Index(es):
    • Date
    • Thread