简体   繁体   中英

cannot convert value of type string to expected argument type int in swift 3

func sortArrayBasedOnStartTime(_ array: NSArray) -> NSArray
{
  for eventDict in array
  {
       let startHourOfThisEvent : String = self.getStartHour((eventDict as! NSArray)["eventStartTime"] as! String)

       if(hourTemp as! String == startHourOfThisEvent)
       {
            arrSpecificHour.add(eventDict as! NSDictionary)
       }
   }
}

Here's your problem

(eventDict as! NSArray)["eventStartTime"]

You are converting a dictionary to an array, which obviously can't be accessed by string, arrays can be accessed only by integers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM