cgpoint
Inheritance from non-protocol, non-class type ‘CGPoint’
This is not possible because you want to inherit a struct from a class. CGPoint is a struct and therefore it does not support inheritance, although it can conform to protocols. If you really want to do this, use composition instead of inheritance. class IYAttachPoint { var point:CGPoint? var holder: String = “No holder” var … Read more
How do I add a CGPoint to NSMutableArray?
The problem is that CGPoint is actually just a C structure it is not an object: struct CGPoint { CGFloat x; CGFloat y; }; typedef struct CGPoint CGPoint; If you are on the iPhone you can use the NSValue UIKit additions to convert the CGPoint to an NSValue object. See this previous answer for examples: … Read more
How do I create a CGRect from a CGPoint and CGSize?
Two different options for Objective-C: CGRect aRect = CGRectMake(aPoint.x, aPoint.y, aSize.width, aSize.height); CGRect aRect = { aPoint, aSize }; Swift 3: let aRect = CGRect(origin: aPoint, size: aSize)
iOS: verify if a point is inside a rect
Swift 4 let view = … let point = … view.bounds.contains(point) Objective-C Use CGRectContainsPoint(): bool CGRectContainsPoint(CGRect rect, CGPoint point); Parameters rect The rectangle to examine. point The point to examine. Return Value true if the rectangle is not null or empty and the point is located within the rectangle; otherwise, false. A point is considered … Read more