My code work on Xcode, but it doesn't work at here, would someone tell me what is the problem of my code. thanks a lot, below is my code:

```
class Solution {
func twoAdd(_ nums: [Int], _ target: Int) -> [Int]{
var indict = [Int]()
for num in nums{
let complement = target - num
var firstIndex = 0
var secondIndex = 0
if let index = nums.index(of: num){
firstIndex = index
}
for n in nums[firstIndex + 1 ..< nums.count]{
//get the complement, retrieve the index of the complement
if n == complement{
if let index = nums.index(of: n){
secondIndex = index
}
//add the element to the indict and exit the loop
indict.append(firstIndex)
indict.append(secondIndex)
return indict
}
}
}
return indict
}
}
```