ThasianX / DivRise

Visualize your dividend growth. DivRise tracks dividend prices of your stocks, gives you in-depth information about dividend paying stocks like the next dividend date and allows you to log your monthly dividend income.
MIT License
96 stars 20 forks source link

Search for stock, stock can't be selected - Xcode 12 #8

Open cheuwleeyeo opened 3 years ago

cheuwleeyeo commented 3 years ago

Hello, Just did a clone(and also install app from the App store); same behavior.

  When selecting search for "stock", it list the stock but I can't seem to select it from the table view ?

  I can see that it can get to the Alphavantage web to get the possible list of stocks.

  Thanks.

Lee

markknopper commented 3 years ago

I think I figured out this problem. In Networking/Request.swift, there is a query to financialmodelingprep.com, but that needs an API Key. So the solution is to add an API key in Configuration.swift, and change the code in func companyProfile to look something like this:

    var urlString = companyProfileURL.replacingOccurrences(of: "{company}", with: identifier)
    urlString.append("?apikey=\(configuration.financialmodelingprepApiKey)")
davidakoontz commented 2 years ago

Has that fix been added to the REPO master / dev?

I just hand rolled it in to my code base (development Mar 22, 2022) and the app is crashing.

// MARK: Portfolio & Search Shared
private func companyProfile(identifier: String) -> AnyPublisher<CompanyProfileResponse, Never> {
    var urlString = companyProfileURL.replacingOccurrences(of: "{company}", with: identifier)
    urlString.append("?apikey=\(configuration.financialmodelingprepApiKey)")
    let url = URL(string: urlString)!
davidakoontz commented 2 years ago

DivRise/Request.swift:72: Fatal error: Unexpectedly found nil while unwrapping an Optional value 2022-03-22 18:44:24.419356-0500 DivRise[21900:1652350] DivRise/Request.swift:72: Fatal error: Unexpectedly found nil while unwrapping an Optional value

line 72 is DateFormatter func fetchUpcomingDividendDate(portfolioStock: PortfolioStock) -> AnyPublisher<UpcomingDividend, Never> { return getCompanyCashFlowStatement(identifier: portfolioStock.ticker, period: "quarter") .map { var date = DateFormatter.fullString.date(from: $0.financials.first!.date)!