scrivo a Swift 3.0Swift 3.0 Risultato di chiamata è inutilizzato
Ho questo codice che mi dà il risultato di allarme di chiamata è inutilizzato
public override init(){
super.init()
}
public init(annotations: [MKAnnotation]){
super.init()
addAnnotations(annotations: annotations)
}
public func setAnnotations(annotations:[MKAnnotation]){
tree = nil
addAnnotations(annotations: annotations)
}
public func addAnnotations(annotations:[MKAnnotation]){
if tree == nil {
tree = AKQuadTree()
}
lock.lock()
for annotation in annotations {
// The warning occurs at this line
tree!.insertAnnotation(annotation: annotation)
}
lock.unlock()
}
ho provato con questo metodo in un altro classi ma mi dà ancora l'errore il codice per insertAnnotation è al di sopra
func insertAnnotation(annotation:MKAnnotation) -> Bool {
return insertAnnotation(annotation: annotation, toNode:rootNode!)
}
func insertAnnotation(annotation:MKAnnotation, toNode node:AKQuadTreeNode) -> Bool {
if !AKQuadTreeNode.AKBoundingBoxContainsCoordinate(box: node.boundingBox!, coordinate: annotation.coordinate) {
return false
}
if node.count < nodeCapacity {
node.annotations.append(annotation)
node.count += 1
return true
}
if node.isLeaf() {
node.subdivide()
}
if insertAnnotation(annotation: annotation, toNode:node.northEast!) {
return true
}
if insertAnnotation(annotation: annotation, toNode:node.northWest!) {
return true
}
if insertAnnotation(annotation: annotation, toNode:node.southEast!) {
return true
}
if insertAnnotation(annotation: annotation, toNode:node.southWest!) {
return true
}
return false
}
Ho provato molti metodi, ma solo non funziona, ma in rapido 2.2 funziona benissimo tutte le idee perché questo sta accadendo ??
Sta dicendo la verità. La tua funzione restituisce un 'Bool', e tu ignori questo fatto con la tua invocazione. Se è questo che intendi fare e vuoi interrompere l'avviso, modifica l'invocazione a '_ = tree! .insertAnnotation (annotation: annotation)'. – pjs
Vedere questo thread: [Il risultato della chiamata a "myFunction" non è utilizzato] (http://stackoverflow.com/questions/37939573/result-of-call-to-myfunction-is-unused). – OOPer
@discardableResult http://stackoverflow.com/a/27261991/2303865 –