ui image won't load anything but array

im basically trying to get the UI image to populate specific aircraft, heres what I have, but I can't seem to get the UI image to let me insert anything but the array:



`@IBAction func displayPressed(_ sender: Any) {
        
        externalPicture.image = UIImage (named: externalArray [1])
        seatingSetup.image = UIImage (named: seatingArray ["\(forPicture())" + "seating"])
     
    }
    
    
    func forPicture() -> String {
        
        var aircraftFullName = ""
        let manuf = aircraftType.selectedRow(inComponent: 0)
        let model = aircraftType.selectedRow(inComponent: 1)
        if manuf < aircraft.count {
            aircraftFullName = aircraft[manuf]
            if let aircraftModels =  models[aircraftFullName] {
                if model < aircraftModels.count {
                    aircraftFullName = aircraftFullName  + " " + aircraftModels[model]
                }
            }
        }
        selectedAircraft.text = aircraftFullName
        
        if aircraftFullName != "0" {}
        return "\(aircraftFullName)"
        
    }


    
    let aircraft = ["Airbus", "Boeing", "Bombardier", "Embraer"]
    var models = [ "Airbus": ["A300", "A320", "A330", "A340", "A350", "A380"], "Boeing": ["B737", "B747", "B757", "767", "777", "787"], "Bombardier": ["CRJ200", "CRJ700/900"], "Embraer": ["ERJ145", "ERJ170", "ERJ190"] ]
    
    var externalArray = ["320outside", "747outside"]
    var seatingArray = ["AirbusA320seating", "BoeingB747seating"]`

Accepted Reply

Claude, I had it right the entire time, I think i was just missing a space... im an *****.. I got it figured out.. now onto the next problem. I can sleep well now before I go back to work tomorrow! Thank you.

Replies

What do you mean :


let me insert anything but the array:


You call

externalArray [1]


So you will always have 747outside. Normal ?


What format for images ? .png ?

Have you copied the images in the project resources ?


Have you checked that the names "320outside", "747outside" match exactly the resources names in the project ? Including uppercase

I feel like I should just get your email address Claude and email you all of my problems... First, thanks for always taking the time to get to me... Here is what I am trying to get it to do... populate the images to match the places when they chose it on the picker... originally i created the array, but that didn't give me an option of how to pick specifically the plane I needed. So then I created the code above to printout the plane type so I could just make it the func: forPicture( ) + (whatever I need) so I can display any photo or data associated to that plane. Am I going about it the wrong way?

Claude, I had it right the entire time, I think i was just missing a space... im an *****.. I got it figured out.. now onto the next problem. I can sleep well now before I go back to work tomorrow! Thank you.

Great.


And don't forget to close the thread before sleeping !


If you want to post an address, I'll send you mine.