[Solved] Populating a UITable with NSDictionary in SWIFT

Here’s what you’ll need to do: First, create a class variable for your data. Put this under your class declaration: var dataDict: [String:AnyObject]? Then, to keep things organized, put your tableView property and your userDetails property directly under the dataDict. @IBOutlet var tableView: UITableView! let userDetails: [String] = UserDefaults.standard.stringArray(forKey:”UserDetailsArray”) Now, your viewDidLoad method should look … Read more

[Solved] Swift – Create charts(bar, line, pie, column) programatically [closed]

After you look into documentation for charts a bit more, you would probably for example if you make a line chart LineChartView() you can have different update functions to change how it looks, for example here is one of mine: func lineChartUpdate(dataPoints: [String], values: [Double]) { //Graph data management var lineChartEntry = [ChartDataEntry]() for i … Read more

[Solved] How to add a UITableview inside a UIImageview programmatically in Swift 3

You can not add a UITableView inside UIImageView. You can take a UIView and add UIImageView and UITableView inside this view. let bgView = UIView.init(frame: self.view.frame) //Frame of the view let imageView = UIImageView.init(frame: CGRect.init(x: 0, y: 0, width: bgView.frame.width, height: bgView.frame.height)) imageView.image = #imageLiteral(resourceName: “imgDefault”) let tableView = UITableView.init(frame: CGRect.init(x: 0, y: 0, width: … Read more

[Solved] how to fix error of “Cannot assign to property: ‘setBarTintGradientColors’ is a method” [closed]

setBarTintGradientColors is a method, meaning it must take an argument (a list of colors). Therefore, you will need something like this instead of assignment: CRGradientNavigationBar.appearance().setBarTintGradientColors(colors) As a rule of thumb, whenever you have set in the name, it is a function, not an attribute, meaning that you will need to pass an argument instead of … Read more

[Solved] Swift count time untill button is pressed [closed]

You can create a timer fileprivate var timer: Timer? var seconds: Int = 0 func runTimer() { timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: (#selector(ViewController.updateTimer)), userInfo: nil, repeats: true) } func updateTimer() { seconds += 1 } Now its just a matter on when you start the timer. Options : viewDidLoad , viewWillAppear, viewDidAppear Then … Read more

[Solved] Swfit- Check whether current time is between two time string

You can set the date formatter defaultDate for today, parse the date strings, create a DateInterval with the start and end date and check if it contains now Date(): extension Formatter { static let today: DateFormatter = { let dateFormatter = DateFormatter() dateFormatter.locale = .init(identifier: “en_US_POSIX”) dateFormatter.defaultDate = Calendar.current.startOfDay(for: Date()) dateFormatter.dateFormat = “hh:mm a” return … Read more

[Solved] Codewars – Swift Solution (Multiply Function)

Edit: in newer versions of Swift, OP’s code works too, since return is no longer needed if there is only oneexpression in the body of a funcion/variable. Details here. You are not doing anything with the result. -> Double indicates that this function should return a Double. For that, you should use the return keyword: … Read more