Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot force unwrap non-optional value of rateValue in the "master" version #241

Open
hatimmakki opened this issue Apr 8, 2022 · 4 comments

Comments

@hatimmakki
Copy link

when using the version of the master branch, and applying the demo code in the Readme, it raise error.

Description

Expected Behavior

It should show the chart as mentioned in the docs

Actual Behavior

error

cannot force unwrap value of non-optional type 'Int'

----------------------------------------

SchemeBuildError: Failed to build the scheme "ExpenseTracker"

cannot force unwrap value of non-optional type 'Int'

Compile LineChartView.swift (x86_64):
/Users/hatim.hoho/Library/Developer/Xcode/DerivedData/ExpenseTracker-hadicoqkbmqusxgevqqrsdohtnpk/SourcePackages/checkouts/ChartView/Sources/SwiftUICharts/LineChart/LineChartView.swift:84:50: error: cannot force unwrap value of non-optional type 'Int'
                                Text("\(rateValue!)%")
                                        ~~~~~~~~~^
                                                 
/Users/hatim.hoho/Library/Developer/Xcode/DerivedData/ExpenseTracker-hadicoqkbmqusxgevqqrsdohtnpk/SourcePackages/checkouts/ChartView/Sources/SwiftUICharts/LineChart/LineChartView.swift:79:47: warning: left side of nil coalescing operator '??' has non-optional type 'Int', so the right side is never used
                                if (rateValue ?? 0 >= 0){
                                    ~~~~~~~~~ ^~~~~
                                              
/Users/hatim.hoho/Library/Developer/Xcode/DerivedData/ExpenseTracker-hadicoqkbmqusxgevqqrsdohtnpk/SourcePackages/checkouts/ChartView/Sources/SwiftUICharts/LineChart/LineChartView.swift:145:97: error: missing argument for parameter 'rateValue' in call
            LineChartView(data: [8,23,54,32,12,37,7,23,43], title: "Line chart", legend: "Basic")
                                                                                                ^
                                                                                                , rateValue: <#Int?#>
/Users/hatim.hoho/Library/Developer/Xcode/DerivedData/ExpenseTracker-hadicoqkbmqusxgevqqrsdohtnpk/SourcePackages/checkouts/ChartView/Sources/SwiftUICharts/LineChart/LineChartView.swift:36:12: note: 'init(data:title:legend:style:form:rateValue:dropShadow:valueSpecifier:)' declared here
    public init(data: [Double],
           ^
/Users/hatim.hoho/Library/Developer/Xcode/DerivedData/ExpenseTracker-hadicoqkbmqusxgevqqrsdohtnpk/SourcePackages/checkouts/ChartView/Sources/SwiftUICharts/LineChart/LineChartView.swift:148:213: error: missing argument for parameter 'rateValue' in call
            LineChartView(data: [282.502, 284.495, 283.51, 285.019, 285.197, 286.118, 288.737, 288.455, 289.391, 287.691, 285.878, 286.46, 286.252, 284.652, 284.129, 284.188], title: "Line chart", legend: "Basic")
                                                                                                                                                                                                                    ^
                                                                                                                                                                                                                    , rateValue: <#Int?#>
/Users/hatim.hoho/Library/Developer/Xcode/DerivedData/ExpenseTracker-hadicoqkbmqusxgevqqrsdohtnpk/SourcePackages/checkouts/ChartView/Sources/SwiftUICharts/LineChart/LineChartView.swift:36:12: note: 'init(data:title:legend:style:form:rateValue:dropShadow:valueSpecifier:)' declared here
    public init(data: [Double],
           ^

Possible Fix

use guard before the line where rateValue! is used

Steps to Reproduce

  1. import the package, choose branch master
  2. paste this code in the view
                        MultiLineChartView(data: [([8,32,11,23,40,28], GradientColors.green), ([90,99,78,111,70,60,77], GradientColors.purple), ([34,56,72,38,43,100,50], GradientColors.orngPink)], title: "Title")

Your Environment

iMac late 2015
macOS Monterey
Xcode Version 13.3 (13E113)

  • Version of this package used:
    master
@vx8
Copy link

vx8 commented May 13, 2022

Same here, any solutions to this?

@evandrobm
Copy link

Same here, any workarround?

@vyas94289
Copy link

Same here, Got the solution?

@iletai
Copy link

iletai commented Oct 17, 2022

Same here, Got the solution?

image

Change another version in SwiftPackage to fix it. The branch master could be not ready for the use swift package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants