According to the following similar question, it's impossible to separate function declarations and definitions.
Separation of function declaration and definition in Swift
However, I was trying to look at the implementation of CGRect and found the following in CoreGraphics/CGGeometry (by right-clicking on "CGRect" in my code and selecting "Jump to Definition").
struct CGRect {
var origin: CGPoint
var size: CGSize
}
extension CGRect {
static var zeroRect: CGRect { get }
static var nullRect: CGRect { get }
static var infiniteRect: CGRect { get }
init()
init(x: CGFloat, y: CGFloat, width: CGFloat, height: CGFloat)
init(x: Double, y: Double, width: Double, height: Double)
init(x: Int, y: Int, width: Int, height: Int)
var width: CGFloat { get }
var height: CGFloat { get }
var minX: CGFloat { get }
var midX: CGFloat { get }
var maxX: CGFloat { get }
var minY: CGFloat { get }
var midY: CGFloat { get }
var maxY: CGFloat { get }
var isNull: Bool { get }
var isEmpty: Bool { get }
var isInfinite: Bool { get }
var standardizedRect: CGRect { get }
mutating func standardize()
var integerRect: CGRect { get }
mutating func integerize()
func rectByInsetting(#dx: CGFloat, dy: CGFloat) -> CGRect
mutating func inset(#dx: CGFloat, dy: CGFloat)
func rectByOffsetting(#dx: CGFloat, dy: CGFloat) -> CGRect
mutating func offset(#dx: CGFloat, dy: CGFloat)
func rectByUnion(withRect: CGRect) -> CGRect
mutating func union(withRect: CGRect)
func rectByIntersecting(withRect: CGRect) -> CGRect
mutating func intersect(withRect: CGRect)
func rectsByDividing(atDistance: CGFloat, fromEdge: CGRectEdge) -> (slice: CGRect, remainder: CGRect)
func contains(rect: CGRect) -> Bool
func contains(point: CGPoint) -> Bool
func intersects(rect: CGRect) -> Bool
}
Did Apple manage to separate the definitions into a different file? Is there a way to find it if I want to see the actual implementation of CGRect?
Apple separated these using special Apple-only tools. You can't recreate this.
The entire implementation of CGRect
is in CoreGraphics/CGGeometry.h
:
struct CGRect {
CGPoint origin;
CGSize size;
};
typedef struct CGRect CGRect;
This is the ObjC equivalent to what the tools converted to Swift (or possibly someone hand coded, since these don't look like many of the other auto-generated Swift code):
struct CGRect {
var origin: CGPoint
var size: CGSize
}
If you mean how the various functions are implemented (like CGRectMake
), no, those aren't available. I don't believe CoreGraphics is open source.