Why can the keyword “weak” only be applied to class and class-bound protocol types

后端 未结 11 1315
清酒与你
清酒与你 2020-12-13 03:14

When I\'m declaring variables as weak in Swift, I sometimes get the error message from Xcode:

\'weak\' may only be applied to class and

11条回答
  •  一向
    一向 (楼主)
    2020-12-13 03:53

    weak only works for reference type, so Xcode would report an error if you are calling from struct (instead of class).

提交回复
热议问题