Swift3警告imagePickerController几乎匹配

时间:2017-03-08 00:06:25

标签: swift3

从旧版本的swift转换时,我收到了

的警告
{{1}}

警告是

  

实例方法   'imagePickerController(:didFinishPickingMediaWithInfo :)'差不多了   匹配可选要求   协议的'imagePickerController(:didFinishPickingMediaWithInfo :)'   UIImagePickerControllerDelegae

这里的问题是,就我的眼睛而言,它抱怨什么以及它所说的几乎匹配是100%相同。我该如何解决此警告?

2 个答案:

答案 0 :(得分:1)

在较新的Swift版本中,方法应为

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any])

然后,警告不会出现。

答案 1 :(得分:0)

这是Swift 5.2中的正确答案

def split_on(lst, val):
    try:
        # get a tuple between the start of lst and the second occurrence of val
        first_idx = lst.index(val)
        remainder = lst[first_idx + 1:]
        second_idx = remainder.index(val) + (first_idx + 1)
        # and recur with the rest of the list beyond the first occurrence
        return [tuple(lst[:second_idx])] + split_on(remainder, val)
    except ValueError: 
        # base case: there's zero or one occurrences of val, 
        # so we just return the whole lst as a tuple
        return [tuple(lst)]

split_on([2,1,1,2,1,2,1,1], 2)
# [(2, 1, 1), (1, 1, 2, 1), (1, 2, 1, 1)]