in Education by
I have an array in one view controller that I want to send to two other view controllers - i am doing it via a prepareForSegue: var userId = "" override func prepare(for segue: UIStoryboardSegue, sender: Any?) { let FollowersUsersViewController = segue.destination as! FollowersUsersViewController FollowersUsersViewController.followersUserId = userId let FollowingUsersViewController = segue.destination as! FollowingUsersViewController FollowingUsersViewController.followingUserId = userId } For the other 2 view controllers I am calling the array like so: View controller 1: var followersUserId = String() let followersProfileId = followersUserId View controller 2: var followingUserId = String() let followingProfileId = followingUserId It seems to work when i send it to one of the view controllers (and comment out the other) but then only one of the buttons work when i run the app. When I do it for both view controllers (as above) i get a Thread 1: signal SIGABRT error - how can it work for both? Appreciate any help :) JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
This is crashing because you are trying to cast wrong view controller. Thats is in a single iteration the segue.destination either FollowersUsersViewController or FollowingUsersViewController. You have conditionally cast it before use. Try this code override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if let controller = segue.destination as? FollowersUsersViewController { controller.followingUserId = userId } else if let controller = segue.destination as? FollowingUsersViewController { controller.followingUserId = userId } }

Related questions

0 votes
    I have an array in one view controller that I want to send to two other view controllers - i am ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    I have an array in one view controller that I want to send to two other view controllers - i am ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    1. Name the term which is used to join two separate arrays into a single array. 2.How are the following ... ii) primitive type data Select the correct answer from above options...
asked Dec 13, 2021 in Education by JackTerrance
0 votes
    I have a base View Controller with various containers inside it. I use them to control the current step ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    1. Name the term which is used to join two separate arrays into a single array. 2. How are the following ... answer fast I want please Select the correct answer from above options...
asked Dec 13, 2021 in Education by JackTerrance
0 votes
    I've managed to read some values into a table view and display them in the Master View of a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I am facing a problem that makes me to waste a lot of time. Each time I insert an element on a ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 14, 2022 in Education by JackTerrance
0 votes
    I am facing a problem that makes me to waste a lot of time. Each time I insert an element on a ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 10, 2022 in Education by JackTerrance
0 votes
    In Ruby on Rails Development (or MVC in general), what quick rule should I follow as to where to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 31, 2022 in Education by JackTerrance
0 votes
    I'm encountering some problems in integrating segue and protocols while implementing a selection list. In my ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    Which of the unit operation is used in Model view controller? (a) Is a Decomposition (b) Part ... Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    I need to Separate multiple Array entries with a newline. the names in the aray value. Again I want ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    What is the performance, disk usage and speed of a compound index(with an array index) and a compound ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    malo 4. Name the term which is used to join two separate arrays into a single array. 5. How are the following passed to the functions? Select the correct answer from above options...
asked Dec 13, 2021 in Education by JackTerrance
0 votes
    What is the name for information sent from robot sensors to robot controllers? (a) temperature (b) pressure (c) feedback (d) signal Please answer the above question....
asked Oct 22, 2022 in Education by JackTerrance
...