IBOutlet properties from Swift structure missing in Objective-C application

I have a structure that I wrote in Swift that contains a class that extends UIViewand has a property IBOutlet.

The class is displayed from my Objective-C application, but Interface Builder will not see IBOutlet. Here is the code:

@objc protocol MyFrameworkDelegate {
    // My delegate methods here
    ...
}

@objc class MyFrameworkClass: UIView {

    @objc @IBOutlet var delegate:MyFrameworkDelegate?
    // The rest of my class here
    ...
}

I set my view class MyFrameworkClassin my storyboard, but the output is delegatenot displayed.

I tried with and without a modifier @objc, no luck. When I test my class from Objective-C, the property appears without IBOutlet.

Has anyone come across something like this?

EDIT

Here is the code generated by Xcode to convert Swift -> Objective-C:

@protocol MyFrameworkDelegate;

SWIFT_CLASS("_Nc9a0xD6MyFrameworkClass")
@interface MyFrameworkClass : UIView
@property (nonatomic) id <MyFrameworkDelegate> delegate;
...

In addition, an error message appears here that I get when I try to start the application:

2014-06-22 21:41:59.095 MyApp Test[75211:17812266] Unknown class MyFrameworkClass in Interface Builder file.
2014-06-22 21:41:59.099 MyApp Test[75211:17812266] -[UIView setDelegate:]: unrecognized selector sent to instance 0xcf5d650
2014-06-22 21:41:59.101 MyApp Test[75211:17812266] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setDelegate:]: unrecognized selector sent to instance 0xcf5d650'

EDIT

:

enter image description here

+4
4

None, .

+2

reason: '-[UIView setDelegate:]: unrecognized selector

, , UIView, MyFrameworkClass. IB.

0

, - // .

myFrameworkDelegate?

, IB , Xcode 6 , , . :)

0

@objc @IBOutlet var delegate:MyFrameworkDelegate?

@IBOutlet var delegate:AnyObject?

.

0

Source: https://habr.com/ru/post/1545604/


All Articles