Cannot assign value of type '(Type1?, Type2?)' to type 'TypeDef' (aka '(Type1, Type2) -> ()')

104 Views Asked by At

I am looking at implementing a swift version of some objective C code. I have a Typedef with the declaration:

void (^)(Class1 * _Nonnull, Class2 * _Nonnull)

The class declarations are:

@class Class1 : NSObject;
@class Class2 : NSObject;

Class2 has a result property as such:

@property (readonly, atomic) Result * _Nullable result;

When trying to use this, I have the following:

Class Properties

var object1: Class1?
var object2: Class2?
var result: Result?
var objectTD: TypedefName?

and some code:

self.object1 = try! Class1()
self.object2 = Class2.init()
self.objectTD = (self.object1, self.object2)
self.Class1!.method(self.objectTD)

The errors I get for the last two lines are:

Cannot assign value of type '(Class1?, Class2?)' to type 'TypedefName' (aka '(Class1, Class2) -> ()')

Value of optional type 'TypedefName?' (aka 'Optional<(Class1, Class2) -> ()>') must be unwrapped to a value of type 'TypedefName' (aka '(Class1, Class2) -> ()')

0

There are 0 best solutions below