Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inheritance from non-protocol, non-class type 'CGPoint'

Tags:

I want to create a custom CGPoint subclass to add some proprieties, but I get this error:

Inheritance from non-protocol, non-class type 'CGPoint'

I have no idea why this is not possible. My class is as simple as this:

import UIKit  class IYAttachPoint: CGPoint {    var holder: String = "No holder"   var unavailable: Bool = false  } 

I've tried adding some libraries like CoreGraphics or QuartzCore without success. If there are already some questions or solutions to this problem, please point me in the right direction.

like image 361
Philip Müller Avatar asked Oct 25 '14 17:10

Philip Müller


1 Answers

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 unavailable: Bool = false } 
like image 103
codester Avatar answered Sep 20 '22 20:09

codester