Sunday, February 11, 2024
HomeiOS Developmentios - Issues with the key phrase "some" with the Swift Charts...

ios – Issues with the key phrase “some” with the Swift Charts framework


I am actually new to Swift, and am making a easy app to trace pellets eaten by my pet axolotl Miyamoto. I’m making an attempt to symbolize the pellet rely visually utilizing the Swift Charts Framework. Nevertheless, I can not fairly determine the best way to remedy this error that I get.

Property definition has inferred sort 'State<Chart<some ChartContent>>', involving the 'some' return sort of one other declaration

I get it each time the ForEach loop is current, though my code is sort of simillar to this instance. Eradicating the ForEach loop lets the code construct and the construct it really works wonderful. I’ve performed some studying on this and some is used when declaring a perform, however I’ve no references to some in my ForEach loop. I’ve learn this submit, however no solutions there appear to be related to my downside. I’ve performed a number of googling about this however there’s nonetheless no answer that works. Listed here are the related components of my code:


...

struct PelletArr: Identifiable {
    
    var pelletdata: Array<String>
    
    let id: Int = 987654321 // simply put some quantity right here to cease errors
}

......

struct ContentView: View {
    
    ......
    
    @State var charliechart: Chart = Chart {
        var pelletarrarr: Array<PelletArr> = []
        var _ = pelletstor.stor.forEach { merchandise in
            pelletarrarr.append(PelletArr(pelletdata: merchandise))
        }
        ForEach(pelletarrarr, id: .pelletdata[0]) { pelletd in
            LineMark(
                x: .worth("Date", DateString().dateNumber(dateStr: pelletd.pelletdata[0])),
                y: .worth("Pellet Rely", pelletd.pelletdata.rely),
                collection: .worth("Axolotl", "A")
            )
            .foregroundStyle(.inexperienced)
        }
        RuleMark(
            y: .worth("Fastened", 10)
        )
    }

    ......

}

NOTES:

  • PelletArr is a wrapper of the particular array, which is saved within the property pelletdata
  • ...... signifies code I deemed irrelevent
  • The formatting of the information storage is Array<Array<String>>, here’s a small instance:
[
["1/1/2003", "", "", "", ""]
     ^        ^   ^   ^   ^
  the date    these are all
 (Australia   clean strings,
   format)     1 equals 1 
                 pellet
]
  • The information is parsed from strings, which is saved within the Swift ‘defaults’.



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments