How to passes data from ViewController to UITabBarController -> UINavigationController ->...
I am try to send data from ViewController to UITabBarController -> UINavigationController -> ViewController and try lots of way but fail to Passes data. After click in button i have asynchronous task and then need to load UITabBarController-ViewController with some data. I already almost try all example but fail to find working code.

func AftergettingAsynchronousData(forUserID userID: String?) {
guard let tabBarController = tabBarController else { return }
let navController = tabBarController.viewControllers?[0] as! UINavigationController
let exploreViewController = navController.topViewController as! ExploreViewController
exploreViewController.userID = userID
}
receiving data
class ExploreViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
public var userID: String?
override func viewDidLoad() {
super.viewDidLoad()
print("userID (String(describing: userID))");
}
}
ios swift uitabbarcontroller
|
show 4 more comments
I am try to send data from ViewController to UITabBarController -> UINavigationController -> ViewController and try lots of way but fail to Passes data. After click in button i have asynchronous task and then need to load UITabBarController-ViewController with some data. I already almost try all example but fail to find working code.

func AftergettingAsynchronousData(forUserID userID: String?) {
guard let tabBarController = tabBarController else { return }
let navController = tabBarController.viewControllers?[0] as! UINavigationController
let exploreViewController = navController.topViewController as! ExploreViewController
exploreViewController.userID = userID
}
receiving data
class ExploreViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
public var userID: String?
override func viewDidLoad() {
super.viewDidLoad()
print("userID (String(describing: userID))");
}
}
ios swift uitabbarcontroller
can you be little more clear. as I understand you want to pass the data between 2 VC Right it depends kind of your data as we have so many option to pass the data. please post some code where you performs the action.
– Avinash Mishra
Nov 22 '18 at 5:28
I just want to passes String type data, but let me edit my code
– Tariqul
Nov 22 '18 at 5:33
1
I edit my code please check. mention that I need to passes data after asynchronous task completed. and when asynchronous task completed and i call AftergettingAsynchronousData method
– Tariqul
Nov 22 '18 at 5:40
1
Ohh sorry I am getting error like this .. Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) ViewController not changes, I just send a string UserId="123101"
– Tariqul
Nov 22 '18 at 5:57
1
When i use prepareForSegue, ExploreViewController loaded but I have a Asynchronous task before getting that data page loaded and that Asynchronous task data nil
– Tariqul
Nov 22 '18 at 6:18
|
show 4 more comments
I am try to send data from ViewController to UITabBarController -> UINavigationController -> ViewController and try lots of way but fail to Passes data. After click in button i have asynchronous task and then need to load UITabBarController-ViewController with some data. I already almost try all example but fail to find working code.

func AftergettingAsynchronousData(forUserID userID: String?) {
guard let tabBarController = tabBarController else { return }
let navController = tabBarController.viewControllers?[0] as! UINavigationController
let exploreViewController = navController.topViewController as! ExploreViewController
exploreViewController.userID = userID
}
receiving data
class ExploreViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
public var userID: String?
override func viewDidLoad() {
super.viewDidLoad()
print("userID (String(describing: userID))");
}
}
ios swift uitabbarcontroller
I am try to send data from ViewController to UITabBarController -> UINavigationController -> ViewController and try lots of way but fail to Passes data. After click in button i have asynchronous task and then need to load UITabBarController-ViewController with some data. I already almost try all example but fail to find working code.

func AftergettingAsynchronousData(forUserID userID: String?) {
guard let tabBarController = tabBarController else { return }
let navController = tabBarController.viewControllers?[0] as! UINavigationController
let exploreViewController = navController.topViewController as! ExploreViewController
exploreViewController.userID = userID
}
receiving data
class ExploreViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
public var userID: String?
override func viewDidLoad() {
super.viewDidLoad()
print("userID (String(describing: userID))");
}
}
ios swift uitabbarcontroller
ios swift uitabbarcontroller
edited Nov 22 '18 at 5:36
Tariqul
asked Nov 22 '18 at 5:05
TariqulTariqul
1,136820
1,136820
can you be little more clear. as I understand you want to pass the data between 2 VC Right it depends kind of your data as we have so many option to pass the data. please post some code where you performs the action.
– Avinash Mishra
Nov 22 '18 at 5:28
I just want to passes String type data, but let me edit my code
– Tariqul
Nov 22 '18 at 5:33
1
I edit my code please check. mention that I need to passes data after asynchronous task completed. and when asynchronous task completed and i call AftergettingAsynchronousData method
– Tariqul
Nov 22 '18 at 5:40
1
Ohh sorry I am getting error like this .. Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) ViewController not changes, I just send a string UserId="123101"
– Tariqul
Nov 22 '18 at 5:57
1
When i use prepareForSegue, ExploreViewController loaded but I have a Asynchronous task before getting that data page loaded and that Asynchronous task data nil
– Tariqul
Nov 22 '18 at 6:18
|
show 4 more comments
can you be little more clear. as I understand you want to pass the data between 2 VC Right it depends kind of your data as we have so many option to pass the data. please post some code where you performs the action.
– Avinash Mishra
Nov 22 '18 at 5:28
I just want to passes String type data, but let me edit my code
– Tariqul
Nov 22 '18 at 5:33
1
I edit my code please check. mention that I need to passes data after asynchronous task completed. and when asynchronous task completed and i call AftergettingAsynchronousData method
– Tariqul
Nov 22 '18 at 5:40
1
Ohh sorry I am getting error like this .. Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) ViewController not changes, I just send a string UserId="123101"
– Tariqul
Nov 22 '18 at 5:57
1
When i use prepareForSegue, ExploreViewController loaded but I have a Asynchronous task before getting that data page loaded and that Asynchronous task data nil
– Tariqul
Nov 22 '18 at 6:18
can you be little more clear. as I understand you want to pass the data between 2 VC Right it depends kind of your data as we have so many option to pass the data. please post some code where you performs the action.
– Avinash Mishra
Nov 22 '18 at 5:28
can you be little more clear. as I understand you want to pass the data between 2 VC Right it depends kind of your data as we have so many option to pass the data. please post some code where you performs the action.
– Avinash Mishra
Nov 22 '18 at 5:28
I just want to passes String type data, but let me edit my code
– Tariqul
Nov 22 '18 at 5:33
I just want to passes String type data, but let me edit my code
– Tariqul
Nov 22 '18 at 5:33
1
1
I edit my code please check. mention that I need to passes data after asynchronous task completed. and when asynchronous task completed and i call AftergettingAsynchronousData method
– Tariqul
Nov 22 '18 at 5:40
I edit my code please check. mention that I need to passes data after asynchronous task completed. and when asynchronous task completed and i call AftergettingAsynchronousData method
– Tariqul
Nov 22 '18 at 5:40
1
1
Ohh sorry I am getting error like this .. Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) ViewController not changes, I just send a string UserId="123101"
– Tariqul
Nov 22 '18 at 5:57
Ohh sorry I am getting error like this .. Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) ViewController not changes, I just send a string UserId="123101"
– Tariqul
Nov 22 '18 at 5:57
1
1
When i use prepareForSegue, ExploreViewController loaded but I have a Asynchronous task before getting that data page loaded and that Asynchronous task data nil
– Tariqul
Nov 22 '18 at 6:18
When i use prepareForSegue, ExploreViewController loaded but I have a Asynchronous task before getting that data page loaded and that Asynchronous task data nil
– Tariqul
Nov 22 '18 at 6:18
|
show 4 more comments
1 Answer
1
active
oldest
votes
Try changing navController.topViewController to navController.rootViewController
Value of type 'UINavigationController' has no member 'rootViewController'
– Tariqul
Nov 22 '18 at 8:16
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424193%2fhow-to-passes-data-from-viewcontroller-to-uitabbarcontroller-uinavigationcont%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try changing navController.topViewController to navController.rootViewController
Value of type 'UINavigationController' has no member 'rootViewController'
– Tariqul
Nov 22 '18 at 8:16
add a comment |
Try changing navController.topViewController to navController.rootViewController
Value of type 'UINavigationController' has no member 'rootViewController'
– Tariqul
Nov 22 '18 at 8:16
add a comment |
Try changing navController.topViewController to navController.rootViewController
Try changing navController.topViewController to navController.rootViewController
answered Nov 22 '18 at 6:52
Kunal_DKunal_D
294
294
Value of type 'UINavigationController' has no member 'rootViewController'
– Tariqul
Nov 22 '18 at 8:16
add a comment |
Value of type 'UINavigationController' has no member 'rootViewController'
– Tariqul
Nov 22 '18 at 8:16
Value of type 'UINavigationController' has no member 'rootViewController'
– Tariqul
Nov 22 '18 at 8:16
Value of type 'UINavigationController' has no member 'rootViewController'
– Tariqul
Nov 22 '18 at 8:16
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424193%2fhow-to-passes-data-from-viewcontroller-to-uitabbarcontroller-uinavigationcont%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
can you be little more clear. as I understand you want to pass the data between 2 VC Right it depends kind of your data as we have so many option to pass the data. please post some code where you performs the action.
– Avinash Mishra
Nov 22 '18 at 5:28
I just want to passes String type data, but let me edit my code
– Tariqul
Nov 22 '18 at 5:33
1
I edit my code please check. mention that I need to passes data after asynchronous task completed. and when asynchronous task completed and i call AftergettingAsynchronousData method
– Tariqul
Nov 22 '18 at 5:40
1
Ohh sorry I am getting error like this .. Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) ViewController not changes, I just send a string UserId="123101"
– Tariqul
Nov 22 '18 at 5:57
1
When i use prepareForSegue, ExploreViewController loaded but I have a Asynchronous task before getting that data page loaded and that Asynchronous task data nil
– Tariqul
Nov 22 '18 at 6:18