Post

Replies

Boosts

Views

Activity

Error "Type does not conform to Protocol"
I have reduced my error to the following code and am stumped trying to resolve... help would be appreciated. xItem does conform to SCListItem which is the protocol requirement for SCList ... so why am I getting the error? protocol SCList { var items: [ any SCListItem ] { get set } } protocol SCListItem { } class xItem: SCListItem { } class xItemList: SCList { // ERROR Type 'xItemList' does not conform to protocol 'SCList' var items: [ xItem ] = [] }
2
0
354
Nov ’23
Parallel Protocol Hierarchies
I am trying to build a hierarchy of protocols that reference each other. Here is a code fragment that explains my predicament... // First I have a hierachy of protocols to represent my data and managing access to it protocol A {} // Placeholder for future functionality protocol AChildP {     var i:   Int { get } } typealias BigThings = Int // These will be much bigger than Ints struct AChild : A {     var i:   BigThings } // I will add funcs here operating on A to manage the data in AChild // Next: Some big collection of AChilds - let say an Array for now let AChilds : Array< AChild > = [ AChild(i:1), AChild(i:2), AChild(i:3) ]     // This will a huge array so when I head over to accessing it from B I only want to reference it // Secondly I want a parallel set of protocols to interpret my data. I don't want to copy it protocol B {     associatedtype U where U == A // I want the base protocols to be constrained to each other (I think!) } protocol BChildP : B {     var s: String { get } } // This is where I get stuck... // If this were OO then perhaps I would create an Array (or whatever collection type I used with AChilds) of objects //  that in turn pointed to a corresponding AChild and then referenced the AChilds. // I could do that here too with a Class I think // However, I want to stay with Structs - but they are value things. I cant seem to work out how to tie a //  BChild to its correcponding AChild without a copy being made. Any helpful pointers (ha) would be appreciated.
2
0
439
Jun ’22
Using Xcode, Git and Arduino
I am wondering if I can use the Xcode with Git to manage an Arduino Library project (h and CPP files). I have tried setting up some simple Empty and External Build projects but have run into some brick walls. When I add a CPP file it is nowhere to be seen in finder. I need to be able to identify where it resides so it can be in the correct place for the Arduino IDE. So I try and add references to files created in the Arduino IDE and although they appear in the project pane, edits in Xcode are not reflected in these files (if I use a workspace they are btw). They also are never tagged with Git badges and disappear when I close the project. Any help would be appreciated,
0
0
478
Jan ’22