0

I encountered a problem when access swift class in objective-c, stored properties in swift cannot be converted to properties in objective-c, such as:

var maxFixedWidth:Float? = defaultMaxWidth {
    didSet{
        self.invalidateIntrinsicContentSize()
        self.setNeedsUpdateConstraints()
    }
}

var itemSpace:Float? = 4 {
    didSet{
        self.invalidateIntrinsicContentSize()
        self.setNeedsUpdateConstraints()
    }
}

These cannot be converted to the following objective-c style properties that should be contained in #import "JDStock-swift.h",

@property (nonatomic, assign) CGFloat maxFixedWidth;

and

@property (nonatomic, assign) CGFloat itemSpace;

It puzzled me for a long time, appreciate for your answers, waiting for you all the time with patient, Thanks!

Hamish
  • 78,605
  • 19
  • 187
  • 280
Sen
  • 1
  • Why are your properties optional when you're giving them a default value? Do you need to be able to assign nil to them? – Hamish Jun 23 '16 at 08:34
  • 2
    Possible duplicate of [Cannot access property of Swift type from Objective-C](http://stackoverflow.com/questions/26366082/cannot-access-property-of-swift-type-from-objective-c) – Hamish Jun 23 '16 at 08:40

0 Answers0