Reputation: 1017
I have my app finish on my emulator, but when I try to use on my phone, I had 2 bugs Ambiguous use of 'subscript'
I was reading this post, but can't fix it. How to solve Ambiguous use of 'subscript' in Swift 2?
The problem is here
let favs = rescataRegistrosFav()
print(favs)
print("-----------------------------------------------")
if(arrayCompleta[row][2] == ""){
cell.imagenMovil.image = nil
}else{
cell.imagenMovil.image = UIImage(named: "mov.png")
}
if(favs.count > 0){
for i in 0...favs.count-1
{
for j in 0...favs[i].count-1
{
print("MUESTRO.....\(favs[i][j] as! String)") //Ambiguous use of 'subscript'
if(favs[i][j] as! String == cell.getNombreCelda()){ ////Ambiguous use of 'subscript'
cell.botonFav.setImage(UIImage(named: imagenFav[1])!, forState: .Normal)
return cell
}
}
}
}
In my restacaRegistrosFavs I cast like other post, but nothing.
func rescataRegistrosFav() -> NSArray{
//_____REPARARAQUI_______
var array = [[String]]()
if((NSUserDefaults.standardUserDefaults().arrayForKey("MIARRAYFAV")) != nil){
return NSUserDefaults.standardUserDefaults().arrayForKey("MIARRAYFAV")! as! [[String]]
}
return array
}
How can I solve this? Thanks!
Upvotes: 2
Views: 459
Reputation: 5787
An NSArray
is effectively an Array<AnyObject>
so there are probably a few types that conform to AnyObject
that also implement a subscript function. Instead of declaring rescataRegistrosFav
as returning an NSArray
try being more specific and declaring it like:
func rescataRegistrosFav() -> [[String]]
Upvotes: 1