The index function is missing
When I try to print the index of the array that any object contains. This does not mean function indexOf
. When I try to manually enter my error I have added a screenshot.
But it works for String array. Can anyone help me solve this problem?
Also here I am showing my code
import UIKit
class ViewController: UIViewController {
var arrayOfAnyObject: [Any] = [Any]()
var arrayOfStringObject: [String] = [String]()
override func viewDidLoad() {
super.viewDidLoad()
print("Index of string object array \(arrayOfStringObject.index(of: "anyString")!)")
print("Index of any object array \(arrayOfAnyObject.index(of: "anyObject")!)")
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
+3
source to share