Post

Replies

Boosts

Views

Activity

I am getting the Errors Type 'CoinModel' does not conform to protocol 'Decodable', and Type 'CoinModel' does not conform to protocol 'Encodable''
here is my code, struct CoinModel: Identifiable, Codable {   let id, symbol, name: String   let image: String   let currentPrice: Double   let marketCap, marketCapRank, fullyDilutedValuation: Double?   let totalVolume, high24H, low24H: Int?   let priceChange24H, priceChangePercentage24H, marketCapChange24H, marketCapChangePercentage24H: Double?   let circulatingSupply, totalSupply, maxSupply, ath: Int?   let athChangePercentage: Double?   let athDate: String?   let atl, atlChangePercentage: Double?   let atlDate: String?   let lastUpdated: String?   let sparklineIn7D: SparklineIn7D?   let priceChangePercentage24HInCurrency: Double?   let currentHoldings: Double?       enum CodingKeys: String, CodingKey {     case id, symbol, name, image     case currentPrice = "current_price"     case marketCap = "market_cap"     case marketCapRank = "market_cap_rank"     case fullyDilutedValuation = "fully_diluted_valuation"     case totalVolume = "total_volume"     case high24H = "high_24h"     case low24H = "low_24h"     case priceChange24H = "price_change_24h"     case priceChangePercentage24H = "price_change_percentage_24h"     case marketCapChange24H = "market_cap_change_24h"     case marketCapChangePercentage24H = "market_cap_change_percentage_24h"     case circulatingSupply = "circulating_supply"     case totalSupply = "total_supply"     case maxSupply = "max_supply"     case ath     case athChangePercentage = "ath_change_percentage"     case athDate = "ath_date"     case atl     case atlChangePercentage = "atl_change_percentage"     case atlDate = "atl_date"     case roi     case lastUpdated = "last_updated"     case sparklineIn7D = "sparkline_in_7d"     case priceChangePercentage24HInCurrency = "price_change_percentage_24h_in_currency"     case currentHoldings       }       func updateHoldings(amount: Double) -> CoinModel {     return CoinModel(id: id, symbol: symbol, name: name, image: image, currentPrice: currentPrice, marketCap: marketCap, marketCapRank: marketCapRank, fullyDilutedValuation: fullyDilutedValuation, totalVolume: totalVolume, high24H: high24H, low24H: low24H, priceChange24H: priceChange24H, priceChangePercentage24H: priceChangePercentage24H, marketCapChange24H: marketCapChange24H, marketCapChangePercentage24H: marketCapChangePercentage24H, circulatingSupply: circulatingSupply, totalSupply: totalSupply, maxSupply: maxSupply, ath: ath, athChangePercentage: athChangePercentage, athDate: athDate, atl: atl, atlChangePercentage: athChangePercentage, atlDate: atlDate, lastUpdated: lastUpdated, sparklineIn7D: sparklineIn7D, priceChangePercentage24HInCurrency: priceChangePercentage24HInCurrency, currentHoldings: currentHoldings)   }   var currentHoldingsValue: Double {     return (currentHoldings ?? 0) * currentPrice   }   var rank: Int {     return Int(marketCapRank ?? 0)   }     } // MARK: - SparklineIn7D struct SparklineIn7D: Codable {   let price: [Double]? }
4
0
3.3k
Oct ’21
Unbalanced calls to begin/end appearance transitions for...
There is a problem in my navigation controller after the google sign in here, Swift  UserDefaults.standard.set(downloadUrl, forKey: "profile_picture_url")                           let vc = self?.storyboard?.instantiateViewController(identifier: "tabBarVC") as! TabBarViewController                           vc.modalPresentationStyle = .fullScreen                           self?.present(vc, animated: true) Here is my code attached Here is the code - https://developer.apple.com/forums/content/attachment/0bb0ef74-76d6-4159-923c-4b867c75f0a3
12
0
5.8k
Mar ’21
Xcode Gives False '{' missing in class error
Xcode says a curly bracket is missing at the end of my class, but it's not here's my code. Xcode says that { is missing in my class, but it's not, which causes other errors at the @objc private functions saying attribute private can only be used in a non-local scope, and also gives another error at my extensions saying declaration is only valid at file scope, here's my code. import UIKit import Foundation import Firebase import FirebaseDatabase import FirebaseAuth import GoogleSignIn import FBSDKLoginKit import SCLAlertView import UserNotifications import FirebaseStorage class SignupViewController: UIViewController { // DatabaseManager.shared.userExists(with: email, completion: { exists in // if !exists{ // // } // }) } } } extension SignupViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate { } }
6
0
1.3k
Mar ’21
Swift segue not working, unexpectedly found nil
Whenever I perform a segue to my SignUpViewController there is an error that says unexpectedly found nil when unwrapping an optional value in the view did load, here is my code. SignUpViewController: Here is the code - https://developer.apple.com/forums/content/attachment/de25efeb-1ffd-47df-8e36-699b0511cb80 Here is the view controller I am performing the segue from: Swift import UIKit class MainViewController: UINavigationController {   override func viewDidLoad() {     super.viewDidLoad()     view.backgroundColor = .white           if isLoggedIn(){       let tabBarController = TabBarViewController()       viewControllers = [tabBarController]     }else{       perform(#selector(showLoginController), with: nil, afterDelay: 0.01)     }   }       fileprivate func isLoggedIn() - Bool {     return UserDefaults.standard.isLoggedIn()   }       @objc func showLoginController() {     let loginController = LoginViewController()     present(loginController, animated: true, completion: {             })   } }
2
0
1.1k
Mar ’21