How to passes data from ViewController to UITabBarController -> UINavigationController ->...












0















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.



enter image description here



     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))");
}

}









share|improve this question

























  • 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


















0















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.



enter image description here



     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))");
}

}









share|improve this question

























  • 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
















0












0








0


1






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.



enter image description here



     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))");
}

}









share|improve this question
















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.



enter image description here



     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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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





















  • 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














1 Answer
1






active

oldest

votes


















0














Try changing navController.topViewController to navController.rootViewController






share|improve this answer
























  • Value of type 'UINavigationController' has no member 'rootViewController'

    – Tariqul
    Nov 22 '18 at 8:16











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
});


}
});














draft saved

draft discarded


















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









0














Try changing navController.topViewController to navController.rootViewController






share|improve this answer
























  • Value of type 'UINavigationController' has no member 'rootViewController'

    – Tariqul
    Nov 22 '18 at 8:16
















0














Try changing navController.topViewController to navController.rootViewController






share|improve this answer
























  • Value of type 'UINavigationController' has no member 'rootViewController'

    – Tariqul
    Nov 22 '18 at 8:16














0












0








0







Try changing navController.topViewController to navController.rootViewController






share|improve this answer













Try changing navController.topViewController to navController.rootViewController







share|improve this answer












share|improve this answer



share|improve this answer










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



















  • 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




















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Paul Cézanne

UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

Angular material date-picker (MatDatepicker) auto completes the date on focus out