[Solved] Creating a global multi dimensional array Swift 4 [closed]

Keep products as structures: struct Product { let id: Int let quantity: Int let price: Double } then define array: internal static var productArray = [Product]() and add your products. let product = Product(id: 1, quantity: 99, price: 1.99) productArray.append(product) internal static prefix lets you to reach the array throughout the app. However, I don’t … Read more

[Solved] “SWIFT” string to name array

use a dictionary. var listArr = [“arr1″,”arr2″,”arr3″,”arr4”] arrays = {“arr1”: [“aa”, “bb”], “arr2”: [“aaa”, “bbb”]} let test1 = arrays[listArr[0]] solved “SWIFT” string to name array

[Solved] How could I select music files in iOS app [closed]

See if below code works for you, Add ‘NSAppleMusicUsageDescription’ to your Info.plist for the privacy authority. Make sure your music is available in your iPhone. It will not work in the simulator. import UIKit import AVFoundation import MediaPlayer class ViewController: UIViewController, MPMediaPickerControllerDelegate { var musicPlayer: AVAudioPlayer? var pickerVC: MPMediaPickerController? var mediaItems = [MPMediaItem]() let currentIndex … Read more

[Solved] Xcode 8: fix for error (has no member ‘backgroundColor’) [closed]

You should get the outlet of the buttons to edit its properties. What you have got is a action of that button for the a particular event like touchUpInside. You should get the Outlet of the button like this: @IBOutlet weak var sampleButton: UIButton! and then set the backgroundColor in the viewDidLoad() : sampleButton.backgroundColor = … Read more

[Solved] how to convert string to date or date to string [closed]

Resum_Controls_Data_txt is type of String not Date, so you have to convert date to string using DateFormatter as follow: let formatter = DateFormatter() formatter.locale = Locale(identifier: “en_US_POSIX”) formatter.dateFormat = “HH:mm E, d MMM y” //add date format whichever you want cell.Resum_Controls_Data_txt.text = formatter.string(from: control.data) 2 solved how to convert string to date or date to … Read more

[Solved] Multiple Unresolved Identifiers in Swift

Looks like you may have an extra curly bracket since the unresolved identifier means that it doesn’t know about the item specified at the location that it’s written. I think you have an extra curly bracket after the “Declare hide keyboard tap” block of code. Proofread your code for small mistakes like that. Usually when … Read more

[Solved] What does the .0 and .1 mean Swift 3.0.1

The .0 in somePoint.0 is accessing the first element (at index 0) of the tuple somePoint. .1 is accessing the second element (at index 1). As others have pointed out, this is covered in the first section of the language guide, “The Basics”. 3 solved What does the .0 and .1 mean Swift 3.0.1