objective c to swift conversion. (#define and weak)

Viewed 134

I am stuck in converting #define and weak from objective c to swift. I tried to use objective c to swift convertor, but I think the result of conversion is not correct.

#define WeakRef(__obj) __weak typeof(self) __obj = self
#define WeakReturn(__obj) if(__obj ==nil)return;
WeakRef(weakSelf);
WeakReturn(weakSelf);

For the second, third and forth lines, I think it should be something like this in Swift

func WeakReturn(obj: Any?) {
    if obj == nil {
        return
    }
}
WeakRef(self)
WeakReturn(self)

In my guess for the first line, it first check the condition of typeof(self) == ??. If true, then set the pointer (__obj) to self. But, I am not sure about what ?? should be.

1 Answers
Related