Type 'AnyObject' does not conform to protocol 'SequenceType'

前端 未结 2 1889
眼角桃花
眼角桃花 2020-12-16 09:44
func loadThumbnails() {

    let paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)
           


        
2条回答
  •  心在旅途
    2020-12-16 10:43

    Apple states in The Swift Programming Language:

    The for-in loop performs a set of statements for each item in a range, sequence, collection, or progression.

    Right now, directoryContent is just conforming to protocol AnyObject, so you can't use for loops over it. If you want to do so, you have to do something similar to the following:

    for item in directoryContent as [AnyObject] {
        //Do stuff
    }
    

提交回复
热议问题