[swift-evolution] [Proposal]: Rectangles and other common structures.

Félix Cloutier felixcca at yahoo.ca
Tue Jan 5 23:45:17 CST 2016


NSRect and CGRect are already the same type and can be used interchangeably:

> typedef CGRect NSRect;


You can easily typealias CGRect to Rect as well if you don't like the two-letter prefix. Otherwise, if you can wait a bit, SE-0005 <https://github.com/apple/swift-evolution/blob/master/proposals/0005-objective-c-name-translation.md> will probably do it for you since it should remove the NS prefix <https://github.com/apple/swift-evolution/blob/master/proposals/0005-objective-c-name-translation.md#stripping-the-ns-prefix> on Foundation APIs.

I'm ot particularly enthusiastic about the suggested Frame and Bounds typealiases though. You could still assign a Bounds to a Frame so I don't think that there's a big win here.

Félix

> Le 6 janv. 2016 à 00:10:31, John Randolph via swift-evolution <swift-evolution at swift.org> a écrit :
> 
> Sorry if this is a repeat, but I’d like to suggest promoting certain structs from Foundation to the Swift standard library.
> 
> As an OS X and iOS developer, it sometimes seems that I work with [GG|NS]Point, [GG|NS]Rect, and [GG|NS]Size almost as much as I use Float or String.  I’d love to see Swift’s standard library include Rect, Point, and Size types, with bridging to make them “just work” with any UIKit or AppKit API that expects their NS or CG equivalents.  Maybe also typealias Frame and Bounds to Rect while we’re at it.
> 
> Thoughts?
> 
> -jcr
> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160106/c0478e25/attachment.html>


More information about the swift-evolution mailing list