I just created a new solution and added a Shared RTL project. Trying to add a struct that adheres to a protocol and seeing this error message: “Interface types not allowed on unmanaged records”
What does that mean? If I remove the protocol adherence then the error goes away.
I assume you’re on Cocoa? it means that Cocoa does no (currently) support structs/records to implement interfaces; only classes can implement interfaces. You’ll probably want to make BulletListCellItem a class, in any case.
I’ll log an issue to improve the error, as i agree its worded confusingly.
We’re looking into it, but i’m not sure if its technically possible, given how structs work on Cocoa (they really are just bytes in memory with the exact fields, they don’t have a VMT and other infrastructure.
I changed from a struct to a class. Part of the protocol definition is as follows:
var xibName: String { get }
The class is currently defined like this:
class BulletListCellItem: TableViewCellItem {
let xibName = "BulletListCell"
}
However, I see this error: Method “TableViewCellItem!.xibName -> RemObjects.Elements.RTL.String” not implemented as required for interface “TableViewCellItem”
Changing the let command to have the type defined fixed this error.
let xibName:RemObjects.Elements.RTL.String = "BulletListCell"
It seems that it cannot infer the type automatically. I see the lack of inference evident when doing something like this:
var path = SharedIndexPath()
SharedIndexPath is a defined class in the shared project. To avoid an error, I need to declare it like this:
Yup, seems that right now, you need to use var to implement a var from an interface, even if its read-only as far as the interface is concerned. I see that Xcode does allow let, so i’ll log an issue for that.
can i get a concrete test case for that? what DOES it see path at, if you don’t specify the type explicitly?
this compiles fine for me:
public class SharedIndexPath {
public func foo() {}
}
var path = SharedIndexPath()
path.foo(); // so it knows what path is