• Apfeltalk ändert einen Teil seiner Allgemeinen Geschäftsbedingungen (AGB), das Löschen von Useraccounts betreffend.
    Näheres könnt Ihr hier nachlesen: AGB-Änderung
  • Das Monatsmotto Juli lautet -- Kitsch as Kitsch can -- Jeder von Euch kann dafür ganz individuell bestimmen, was für ihn Kitsch ist und ein Foto davon einsenden. Macht mit, traut Euch! --> Klick

Initializer for conditional binding must have Optional type, not 'CLLocation'

Thaddäus

Golden Noble
Registriert
27.03.08
Beiträge
18.463
<div class="bbWrapper">Hi Leute....<br /> <br /> Das hier ist meine Methode in Xcode 9 und Swift 4. Allerdings wirft sie mir den untenstehenden Fehler aus... Irgendjemand eine Idee wo mein Denkfehler liegt?<br /> <br /> <div class="bbCodeBlock bbCodeBlock--screenLimited bbCodeBlock--code"> <div class="bbCodeBlock-title"> Code: </div> <div class="bbCodeBlock-content" dir="ltr"> <pre class="bbCodeCode" dir="ltr" data-xf-init="code-block" data-lang=""><code>func showSightingsOnMap(location: CLLocation) { let circleQuery = geoFire!.query(at: location, withRadius: 2.5) _ = circleQuery.observe(GFEventType.keyEntered, with: { (key, location) in if let key = key, let location = location { let anno = PokeAnnotation(coordinate: location.coordinate, pokemonNumber: Int(key)!) self.mapView.addAnnotation(anno) }</code></pre> </div> </div><br /> <blockquote data-attributes="" data-quote="" data-source="" class="bbCodeBlock bbCodeBlock--expandable bbCodeBlock--quote js-expandWatch"> <div class="bbCodeBlock-content"> <div class="bbCodeBlock-expandContent js-expandContent "> Initializer for conditional binding must have Optional type, not 'CLLocation' </div> <div class="bbCodeBlock-expandLink js-expandLink"><a role="button" tabindex="0">Zum Vergrößern anklicken....</a></div> </div> </blockquote></div>
 

MacApple

Schöner von Bath
Registriert
05.01.04
Beiträge
3.652
<div class="bbWrapper">Die Variable ‚location‘ ist kein Optional. Deshalb ist das if let Konstrukt überflüssig.</div>
 
  • Like
Reaktionen: Thaddäus