0

I would like to know how to put name value "ok" and "123" into first array which is ["here"] I want other arrays to be empty.

    import Foundation
    import CoreLocation

    class Spot {

        let name: String
        let location: CLLocation

        init (lat: CLLocationDegrees, lng: CLLocationDegrees, name: String = "") {
            self.location = CLLocation(latitude: lat, longitude: lng)
            self.name = name
        }
    }//class

    extension Spot {

        static var list: [Spot] {

            return [

                Spot(lat: 35.124585, lng: 135.154821, name: "ok"),
                Spot(lat: 35.05406, lng: 136.215414, name: "123")
    ]
        }
    }

    var array = [["here"],[],[],[],[],[]]

1 Answer 1

1

You need to access the first array in your array of arrays, and then insert those elements in it like this:

array[0].append("123")
array[0].append("ok")

You can achieve the same goal this way:

array[0] += ["123", "ok"]
Sign up to request clarification or add additional context in comments.

1 Comment

sorry for the late reply. thank you so much I could achieved what I wanted to. thank you again!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.