[swift-users] @escaping may only be applied to parameters of function type

Rick Mann rmann at latencyzero.com
Tue Sep 13 21:27:49 CDT 2016


I'm trying to write this function. The errorHandler: parameter is modeled after the NSFileManager enumerate() function. If I include the @escaping you see there, I get the error "@escaping may only be applied to parameters of function type".

The second parameter, iterator:, seems to have no problems with @escaping.

func
iterate(directory inURL: URL?,
        includingPropertiesForKeys: [URLResourceKey]? = nil,
        options: FileManager.DirectoryEnumerationOptions = [],
        errorHandler inErrorHandler: (@escaping (URL, Error) -> Bool)? = nil,
        iterator inIterator: (@escaping (URL) throws -> ())) rethrows
{
}

I'm not sure why I can't apply @escaping here. Can anyone enlighten me? Thank you.

-- 
Rick Mann
rmann at latencyzero.com




More information about the swift-users mailing list