I tweaked some things for Swift 2 - including having to put a ‘?’ after the title and subtitle fields however I now seem to have a problem with types/optionality. any ideas? the line " let placemark = MKPlacemark(coordinate: coordinate, addressDictionary: addressDictionary)" is now coming up with the following error
cannot convert value of type ‘String?’ to expected argument type ‘(String : AnyObject)?’
full code is:
`class Artwork: NSObject, MKAnnotation{
let title: String?
let locationName: String
let discipline: String
let coordinate: CLLocationCoordinate2D
For some reason when I added the rest of the pins, they no longer have the detail disclosure info button and I’m not sure where I messed up. The code with the statue still shows it, but when I remove that bit it disappears.
I’m having problems with the second return statement for func mapView. It says you can’t return a nil for MKAnnotationView. Any idea of what I should return?
Lynn’s second post nailed it: the signature of that method has changed and it now returns an Optional. Accept the warning’s fix, which adds ? to the return type:
But I can’ figure out how to call it in VCMapView.swift
view.pinColor() no longer exists in the MKPinAnnottationView and I don’t see a method for it. What should I be doing?
I tried view.tintColor() = annotation.pinTintColor() but that changes the info button color instead.
i am having issues in loadInitialData function… More scpecific, i would like to know if in the //4 something is changed in swift 2.
`// 3
if let jsonObject = jsonObject as? [String: AnyObject],
// 4
let jsonData = JSONValue.fromObject(jsonObject)?[“data”]?.array {
for artworkJSON in jsonData { …
``
It doesnt recognize the JSONValue type… maybe its just the syntax?
I’m having a similar problem - if not the same - but I have the JSON.swift file added to the project, installed all cocoa pods and SwiftyJSON into the project, and still have some errors.
// 3
if let jsonObject = jsonObject as? [String: AnyObject],
// 4
let jsonData = JSONValue.fromObject(jsonObject)?["data"]?.array {
for artworkJSON in jsonData {
if let artworkJSON = artworkJSON.array,
// 5
**artwork = Artwork.fromJSON(artworkJSON) {**
artworks.append(artwork)
}
in the highlighted line I have the error:
Cannot convert value of type ‘[JSONValue]’ to expected argument type ‘JSON’
The JSON file is in the project (copied also), as shown in the figure.
Thanks! Ok I changed that and fixed that error, I have another one. I changed to SwiftyJSON so I could fix some other errors I had, from stackoverflow, but that is past now.
I followed all the steps from this tutorial but I didn’t want the three tabs on top of the screen. I made a screen with only the map itself, and its functions. I got all working until the options inside the Pin, they don’t appear for me, neither the Maps app, though I have made this option on calloutAcessoryControlTapped, as I show in the figure: