类型转换对于AnyObject来表示任何引用类型的实例

时间:2016-05-31 12:53:34

标签: swift anyobject

String = "ask not what your country can do for you ask"
words = ["ask","not","what","your","country","can","do","for","you","ask"]
positions = [1,2,3,4,5,6,7,8,9,1]

for word in String():
   if not word in words:
      words.append(word)
   i = words.index(word)
   positions.append(i)

s = "" 
for i in positions:
   s = s + words[i] + " "

print(s)

当我在游戏场中编写此代码时,它会出现以下错误类型'测试'不符合协议' AnyObject'

我猜它失败了,因为struct是一个值类型而不是引用类型。 但是当我运行这段代码时

 </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal" onclick="resetFunction();">Yes</button>
            <button type="button" class="btn btn-default"  onclick="reprintLabel();">No, Reprint Label</button>
        </div>
    </div>

有效 但这些都是值类型,但在这种情况下没有给出错误为什么?

1 个答案:

答案 0 :(得分:0)

对于你的成功案例,幕后会有一些转换。

尝试在附加的末尾添加此内容,以查看发生了什么:

$sql = "SELECT id 
        FROM location
        WHERE id IN (?)";
$locations = $this->db->query($sql, $this->input->post('location'));