Iglistkit: IGListDiffable and Non-class type

Created on 12 Oct 2016  路  1Comment  路  Source: Instagram/IGListKit

New issue checklist

Is there any reason IGListDiffable could not be implemented on Struct?
the following code returns this error:
Non-class type 'Foo' cannot conform to class protocol 'IGListDiffable'

struct Foo: IGListDiffable {
  let id: String

  func diffIdentifier() -> NSObjectProtocol {
    return id as NSObjectProtocol
  }

  func isEqual(object: Any?) -> Bool {
    return false
  }
}
  • Library version(s): 1.0.0
  • iOS version(s): 10.0
question

Most helpful comment

Thanks @pgherveou !

See the discussion in #35.

In short, this is a limitation in the Swift compiler when bridging _from_ Objective-C _to_ Swift. It's difficult (or impossible) to determine if reference semantics are required, or not. Thus, protocols are imported as @objc which requires a reference (class) type.

>All comments

Thanks @pgherveou !

See the discussion in #35.

In short, this is a limitation in the Swift compiler when bridging _from_ Objective-C _to_ Swift. It's difficult (or impossible) to determine if reference semantics are required, or not. Thus, protocols are imported as @objc which requires a reference (class) type.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kleiberjp picture kleiberjp  路  3Comments

PhilCai1993 picture PhilCai1993  路  3Comments

Przemyslaw-Wosko picture Przemyslaw-Wosko  路  3Comments

kanumuri9593 picture kanumuri9593  路  3Comments

rnystrom picture rnystrom  路  3Comments