How To Pass Data Between View Controllers In Xcode 8 (Swift 3)

  Рет қаралды 83,831

The Swift Guy

The Swift Guy

Күн бұрын

Пікірлер: 152
@sdsport2004
@sdsport2004 7 жыл бұрын
Excellent job. I have been all over the internet looking for good example of how to set up a segue to another ViewController and wasn't having any luck until I came across your quick tutorial. Excellent explanation and easy to follow. This is the second time you've rescued me today! Thanks!
@gjermundification
@gjermundification 6 жыл бұрын
I have now watched 3 of your videos, I find that you are very good at grasping the essence of your topic and you are really good at not derailing your topic.
@kasiabialostocki699
@kasiabialostocki699 7 жыл бұрын
For an utter noob, you make learning to code fun and easy. You are an awesome teacher!
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
Thank you, super glad to hear that!:)
@timmy334
@timmy334 7 жыл бұрын
Thanks! I getting into iOS development and your tutorials are always helpful and concise. This is a good one.
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
Thank you!:)
@nooral-awadi9526
@nooral-awadi9526 5 жыл бұрын
Thank you so much! Short and to the point. Please keep posting great content on Swift
@chopchopcuts1902
@chopchopcuts1902 7 жыл бұрын
0:27 What an emphatic keyboard press!! Great tutorial!
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
haha, thank;)
@andyal868
@andyal868 5 жыл бұрын
It helps to watch it twice. In general, many videos I get on a second try. He explains pretty good though
@azevedo1236id
@azevedo1236id 7 жыл бұрын
congratulations man, i am from brazil and here we has a very limited videos about swift, but yours videos are great, very simples and quick!! keep doing this !!
@bigmtnstudio
@bigmtnstudio 7 жыл бұрын
Quick and simple! I like that. Thanks, Swift Guy!
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
Thank you for your comment Mark! Love watching your videos!:)
@bigmtnstudio
@bigmtnstudio 7 жыл бұрын
Wow, that's awesome. I love your channel, love your enthusiasm for programming!
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
Thank you, I appreciate you saying that!:)
@Lelvl8
@Lelvl8 7 жыл бұрын
Mark > TSG, Yeah sry bro :) liked
@GruntyGunner
@GruntyGunner 6 жыл бұрын
1:52 I just wanted to point out that dragging a segue from back to the previous VC is generally not recommended and that you should use an unwind segue instead. I know you probably know this and it's fine for this tutorial but just wanted to clarify for people brand new to Xcode.
@agustinachaer
@agustinachaer 7 жыл бұрын
great video! The only thing that I would change is the use of a show segue to go back. I know that probably for simplicity purposes you did it that way here but it is not a good practice at all. In this example you are stacking those view controllers one over the other repeatedly and never dismissing them. I don't know if it maintains multiple instances of the same view controllers so starts to take up a lot of space or if a new instance of a viewcontroller is created, the previous one of that same viewcontroller is destroyed. In any case, it is not a good practice therefore you should not be doing it in a tutorial without explaining that it should not be done cause beginners pick up on everything you teach. Yaser's implementation of the back button is the correct one. BTW recently I had to implement a custom transition for a segue cause i wanted it to slide in from the left and be dismissed to the left too and I though of it to be very interesting.
@statsbruh
@statsbruh 7 жыл бұрын
good catch
@frankdragon
@frankdragon 7 жыл бұрын
Hey man really good videos! Shorts , meaningful and touching a lot of topics
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
Thank you so much for your comment!:)
@dianewarde6074
@dianewarde6074 6 жыл бұрын
That should say “trying to learn to code. Thanks for all your helpful tutorials.”
@arad907
@arad907 6 жыл бұрын
As Mark said, quick & simple & great... Thanks.
@DarylNotDead
@DarylNotDead 6 жыл бұрын
Hi. In the “sending” view controller when setting your var, you could try logic testing. Something like- If mystring “” then mystring =mystring In theory when the sending controller is recalled it will keep the data as is if it is not “”. That may work.
@aybarslan
@aybarslan 5 жыл бұрын
Its also works on swift 4 xcode 10 Great Job !
@akshaydewan5608
@akshaydewan5608 4 жыл бұрын
this video was a great help!
@khaabd8916
@khaabd8916 7 жыл бұрын
Your tutorial is amazing please keep going
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
Super glad to hear that!:)
@GunnarDeMinecraft
@GunnarDeMinecraft 6 жыл бұрын
Great, quick video!
@webmasterashishgaur
@webmasterashishgaur 6 жыл бұрын
you are not guy, you are the best swift guy
@yaserbinabdullah3900
@yaserbinabdullah3900 7 жыл бұрын
Thank you man, for this amazing tutorial. However, you forgot the back button but I did it for you and for you guys @IBAction func back(_ sender: Any) { dismiss(animated: true, completion: nil) } I have called the button (back) then I used dismiss code to return to the same page without losing the data. which that keep free space in the RAM of the phone. keep up
@yaserbinabdullah3900
@yaserbinabdullah3900 7 жыл бұрын
if you want to have a new page to enter new text just connect the button to the firstViewController without the code that I have provided before
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
thank you for your contribution Yaser!
@yaserbinabdullah3900
@yaserbinabdullah3900 7 жыл бұрын
You are welcome
@papii_6669
@papii_6669 6 жыл бұрын
Yaser Abdullah I noticed he forgot it too but then I realized that he did a simple seg for it :)
@Zo91709
@Zo91709 6 жыл бұрын
Yaser - is this what i would do if i needed the data from the second view controller save and displayed back on the first view controller?
@catcatcatcatmeow
@catcatcatcatmeow 6 жыл бұрын
Thanks, I'm super new to swift and this tutorial is neat and amazing, it helps a lot :)
@shoukimichaelsouri7251
@shoukimichaelsouri7251 7 жыл бұрын
Love these quick tutorials!! Have a quick question. How could you pass a variable from firstViewController to a thirdViewcontroller without a direct segue from the first to the third with a flow like this first-->second-->third, each with a segue to the next?
@pravishankar
@pravishankar 6 жыл бұрын
Great tutorial - Am following these steps to pass an array between viewcontrollers...do you have a video for that?
@QAInsights
@QAInsights 7 жыл бұрын
Thanks for the tutorial. How to pass data from VC A to B to C? Please help me out.
@prithviapportunity7374
@prithviapportunity7374 6 жыл бұрын
Awesome dude!! simple to understand.
@BernaLuz
@BernaLuz 5 жыл бұрын
Absolutely useful and easy. Thank you.
@BlaBla-dw9mg
@BlaBla-dw9mg 6 жыл бұрын
Thank you for your amazing tutorials.
@francescomusto4918
@francescomusto4918 6 жыл бұрын
Hi Swift Guy. This is my first time in your channel. But I have a big question about passing data between View Controllers. There is a simply way to make two View Controllers communicate without a direct link but through a TabBarController and a Navigation Controller? Thanks a lot!
@ricardoisidro7640
@ricardoisidro7640 6 жыл бұрын
Nice example, man. It was really helpful for start, but now I wanna now what happens if I have more than one viewcontroller (suppose a form splitted in two viewcontrollers). Do I need to add a segue among each viewcontroller and the final VC? Thanks a lot!
@eyerusalemwoldu2144
@eyerusalemwoldu2144 7 жыл бұрын
Thank you, It is very informative and simple!!!
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
Glad to hear that!:)
@oscarlofqvist240
@oscarlofqvist240 6 жыл бұрын
Thank you, Swift Guy, great video! I have a question is this a safe way to pass data? Like a user email or password?
@Adamzdsad
@Adamzdsad 7 жыл бұрын
Hello , i have a question which im hoping you could answer. I am building a restaurant application, and was wondering what would be the best way for me pass on order information from a "restaurant menu" view to the "checkout" view e.g. User selecting Cheese Burger x1 from menu > Then pressing add item . Love your vids by the way, learnt so much :)
@bigmtnstudio
@bigmtnstudio 7 жыл бұрын
Amzkeh, you could use the same concept Swift Guy uses. Except instead of a string you could create your own struct/class to hold orders like: class Orders { var itemID = 0 var itemName = "" var itemCount = 1 } Then you just have an array on the menu page: var orders: [Orders] = [] Append items to this array and when the user taps "Checkout" you pass that variable "orders" to the checkout viewcontroller!
@nouraalfaris1778
@nouraalfaris1778 7 жыл бұрын
thank u fro the fantastic Video i want to ask u about if i want to move data was retrieved from DB then i want to store it again with other View i will store data inside it into database how can i do that ?
@guillermocast01
@guillermocast01 7 жыл бұрын
Great video! Thanks Bud, really appreciated.
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
:)
@mohamedsudheer9163
@mohamedsudheer9163 6 жыл бұрын
Ppl like The Swift Guy will go to iOS heaven edit: helped me solve a similar problem to the one shown in the video
@carlomagnocondesaldana5860
@carlomagnocondesaldana5860 6 жыл бұрын
Simple and great. Thanks brother!
@carlosfernandez6470
@carlosfernandez6470 7 жыл бұрын
Thanks quick and easy .. love it
@searchingwhat6835
@searchingwhat6835 6 жыл бұрын
Great tutorials dear keep it up thanks for this wonderful tutorials
@AbdullahJirjees
@AbdullahJirjees 5 жыл бұрын
Sir thanks a lot to your video, I modified it by making the seondViewController to be TableViewController, but I faced this issue with the label, I cannot figure it out "Main.storyboard: error: Illegal Configuration: The label outlet from the TableViewController to the UILabel is invalid. Outlets cannot be connected to repeating content."
@tubex1300
@tubex1300 6 жыл бұрын
Hi It's really save a lot of time Many thanks for this wonderful vid
@fraiserroberts6910
@fraiserroberts6910 7 жыл бұрын
Thankyou for the video, just wondered is there a way to pass data, so that I can pause audio using a button on a different view controller?
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
What you could do, is create an extension to your view controller, in which you create your audio player. That way the audio player will be accessible throughout all of your view controllers. You will then also be bale to pause it;)
@SurendraKumar-si8lw
@SurendraKumar-si8lw 7 жыл бұрын
Use protocal and delegate method. create protocal of BUtton View Controller and implement delegate in Audio View Controller.
@ArtemLebedko
@ArtemLebedko 6 жыл бұрын
Briefly and clearly Thank you buddy :3
@ismael7155
@ismael7155 6 жыл бұрын
Thanks! Keep up the good work!
@youngdomsey
@youngdomsey 6 жыл бұрын
Thats an amazing tutorial! Thank you!
@Peech
@Peech 6 жыл бұрын
How can I make the text that we inputted in the TextField remain in the label even when you close the app entirely?
@studentprogrammer9115
@studentprogrammer9115 7 жыл бұрын
hey this is help helpful, but is there a way I can send the date from a UIbutton(which was tittleselected from a picker view) to a label in another VC?
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
Yes, make sure to take a look at my video on how to use multiple view controllers!:)
@PeterSchimpl
@PeterSchimpl 7 жыл бұрын
Great stuff - thanks for sharing!
@goktugguvercin8069
@goktugguvercin8069 7 жыл бұрын
Your tutorials show us how we can send data from first view controller to second view controller. In other words, this is forward data transferring. Is there a tutorial of how we can take data from second view controller to first view controller ? My aim is taking data from second view controller and add it into a table view in first view controller.
@abdulrahmanalshamrani1765
@abdulrahmanalshamrani1765 7 жыл бұрын
You are amazing teacher ^_^
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
Thank you!:)
@BalaaLyf
@BalaaLyf 4 жыл бұрын
Please upload one more video for this pass data.. Multiple labels and multiple textfields.. Data transfer and save it
@mikefrank2643
@mikefrank2643 4 жыл бұрын
How would it be for the saved data to be seen in several viewcontrollers without using segue ???
@jacksonrogers2147
@jacksonrogers2147 6 жыл бұрын
Would I be able to do something with this technique when taking a variable from a text field and then simultaneously putting it into multiple tabs of a tabbed project (i.e. one with a table view, one with a map, one with a summary)?
@carrot7143
@carrot7143 6 жыл бұрын
Thanks for the tutorial! But I was wondering how can I retain the data that was entered in the first view controller. So when i return to that view controller the we previously entered in the text fields are unchanged?
@nicolasthevenard1913
@nicolasthevenard1913 7 жыл бұрын
I love you tutorial, thank you
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
Glad to hear that, you are welcome!:)
@olivierdumont9223
@olivierdumont9223 6 жыл бұрын
Heyp, so easy!!! Many many thanks Seb! :-)
@papii_6669
@papii_6669 6 жыл бұрын
Great job bro
@Zo91709
@Zo91709 6 жыл бұрын
Nice video- what if i want to send the data entered in the second view controller- back to the first. For example- say once you type your name and push enter in the first view, it pushes the data to the second view- however, once you're on the second view and you push save - it automatically goes back to the first view, and the name you entered is automatically saved. Please let me know if you have a solution. Thank you the Swift Guy!!
@tdrusk
@tdrusk 7 жыл бұрын
Thank you thank you thank you!
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
You are so welcome!:)
@McD8
@McD8 7 жыл бұрын
Just one question: how would you do this with a tab interface? I would like to enter text in one tab and have it effect a label in another tab. Thanks!
@raven3107
@raven3107 6 жыл бұрын
Can you make a video on Arrays?
@الياسيولأمل
@الياسيولأمل 7 жыл бұрын
Hello Can you explain to me how to fetch a record from a permanent store using the search tool
@saikrishna0512
@saikrishna0512 7 жыл бұрын
can we do the same with storyboards??
@ilanepena7661
@ilanepena7661 5 жыл бұрын
Hey nice video but I'm trying to do the same by passing doubles and then add these numbers to others but it doesn't work it says Binary operator '+=' cannot be applied to operands of type 'String' and 'Int'
@warmachine3071
@warmachine3071 7 жыл бұрын
Thanks so much bro!!
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
You are so welcome brother!:)
@rahulnetha3190
@rahulnetha3190 6 жыл бұрын
how long will the data will be saved ?
@רוןאבות
@רוןאבות 6 жыл бұрын
Thank you! very helpful
@marianagrnk
@marianagrnk 3 жыл бұрын
I need to pass an array of data from the 1st to the 4th view controller, I tried this way but doesn’t work for me cause the views are not directly connected. Any help I could get pleaseeee?
@renederv
@renederv 5 жыл бұрын
Hey What do I need to change from this video I’ve learned if i dont want to switch to the other ViewController immediately after clicking on Enter. So when i click Enter i stay on the first ViewController and dont switch to the second? Thanks :-)
@jrgibson
@jrgibson 6 жыл бұрын
How do you pass data from ViewController A to B and then the same data to ViewController C?
@awadsandal6187
@awadsandal6187 6 жыл бұрын
guess what u r simply amazing
@ktmman1503
@ktmman1503 7 жыл бұрын
Hi, did you get my email about the Apple Nav.. wont work with versions less the 10.X .. help please... Craig.
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
Replied;)
@elitiauniverse2871
@elitiauniverse2871 4 жыл бұрын
Thank you ^^
@bellekiller
@bellekiller 7 жыл бұрын
well, a confusion here. the seguway thing, is it a built in name or a name you made up.....?
@SullyGamer17
@SullyGamer17 7 жыл бұрын
Could you do a tutorial on custom segues please!
@mirsaelenaalvarez3817
@mirsaelenaalvarez3817 6 жыл бұрын
Hola, Muchisímas gracias!!
@lukee386
@lukee386 7 жыл бұрын
Are you doing anymore 'i test your apps'??
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
My goals is to get the next one out on Friday!:)
@lukee386
@lukee386 7 жыл бұрын
The Swift Guy nice! Thanks. I left a link to my app in the last I test your apps video
@GarryFanata
@GarryFanata 7 жыл бұрын
Why did you put the segue on the view controller and not on the "enter" button
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
I would take a look at this video. In it, I explain the different types of segues, and why you use one over the other:) How To Trigger A Segue In xCode 8 (Swift 3.0)
@dianewarde6074
@dianewarde6074 6 жыл бұрын
Swift Guy, your tutorials are very clear. However I am getting a “expected declaration” error when I type the line label.text = myString. I am using different names for the label and string, but I have checked and double checked the spelling and capitalization for correctness. I can’t find anything on the net that deals with expected declaration for such simple code. Any ideas? I am a retired person trying to learn to nos for all your helpful tutorials.
@joenaveau
@joenaveau 5 жыл бұрын
You have to write your code in a function. It can be the override func viewDidLoad() in the ViewController class, among others. it's 10 months later, I don't know if this is still relevant or not! :)
@LebenWerden
@LebenWerden 6 жыл бұрын
hello. i Have a Question in 4:45 Why we don^t fill our Outlet named label ?
@warmachine3071
@warmachine3071 7 жыл бұрын
how would i make it so when the user comes back their username stays the same and it starts on the secondviewcontroller when you launch the app?
@jessica6612
@jessica6612 6 жыл бұрын
Nice and simple tutorial. But you shouldn't be linking your second view to the first view like you did. You have to dismiss the second view when you click the "back" button, otherwise you will have many instances running on the background, and depending on the app, that will slow down the process.
@xXXDgrayManXXx14
@xXXDgrayManXXx14 4 жыл бұрын
what happens if you want to pass a function or a dictionary ? @The Swift Guy
@javiergutierrez5833
@javiergutierrez5833 5 жыл бұрын
Thanks!
@rishavbhowmik757
@rishavbhowmik757 7 жыл бұрын
Can you make a tutorial on OS_Log
@perezwillie-nwobu3269
@perezwillie-nwobu3269 7 жыл бұрын
Can you permanently save it in an array of another view controller?
@perezwillie-nwobu3269
@perezwillie-nwobu3269 7 жыл бұрын
How do you do that? I tried using userdefaults.standard. but Iit didn't work. don't know if I did it right, any ideas Tiffany?
@SurendraKumar-si8lw
@SurendraKumar-si8lw 7 жыл бұрын
if you saving Data permanently, means you are not passing data OR no need to pass data then. just save value using userdefauts in firstViewControoler . ans I secondViewController just retrive default Value and save some varibale like array.
@perezwillie-nwobu3269
@perezwillie-nwobu3269 7 жыл бұрын
well it kinda didn't work for me. my array in the second viewController is in a global variable
@manuelponce1568
@manuelponce1568 5 жыл бұрын
dope! thanx
@1TheSwiftGuy
@1TheSwiftGuy 5 жыл бұрын
;)
@intellectlogic99
@intellectlogic99 7 жыл бұрын
unable to do it getting this error Use of unresolved identifier 'segue' on this line if let registration_otp = segue.destination as! registration_otp
@alidhan1299
@alidhan1299 6 жыл бұрын
Thank you
@EzDoesntExist
@EzDoesntExist 6 жыл бұрын
thanks!
@LebenWerden
@LebenWerden 6 жыл бұрын
And no unWind ?
@donk7283
@donk7283 7 жыл бұрын
wondering if anyone knows a way to send multiple text field over to there own separate label in the next view controller?
@LebenWerden
@LebenWerden 7 жыл бұрын
2:22 You take a Cocoa Touch file. Why not a swift file?
@shawntaylor9509
@shawntaylor9509 7 жыл бұрын
Create a Swift file and see the difference.
@studentprogrammer9115
@studentprogrammer9115 7 жыл бұрын
Ok I got that, But I’m stuck to sending data from a tableview(consist of array) to a label any help.. even my TAdon’t know how to do that 🤦🏾‍♂️
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
Hi, do you want to print the information of the whole tableview into a label, or just the value that the user tapps on in the table view?
@studentprogrammer9115
@studentprogrammer9115 7 жыл бұрын
Just the value the user click on.. 👌🏿 damn Man U got that so easily, when my TA took 2 hours to understand just the question. Smh 🤦🏾‍♂️
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
Haha;) Have you taken a look at this video? This should explain how to go about doing it:) kzbin.info/www/bejne/d2e6nWuviNeCkKs
@SurendraKumar-si8lw
@SurendraKumar-si8lw 7 жыл бұрын
By the way . what is TA means ? :D
@studentprogrammer9115
@studentprogrammer9115 7 жыл бұрын
Teacher Assistant lol
@MusikRey
@MusikRey 7 жыл бұрын
Thanks you (y)
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
You are welcome:)
@jiyoo5767
@jiyoo5767 6 жыл бұрын
500th like!
@kamilpetryczkiewicz1700
@kamilpetryczkiewicz1700 7 жыл бұрын
I get the signal sigabrt ;( why?
@younessaitouaddi2268
@younessaitouaddi2268 5 жыл бұрын
nice
@khaabd8916
@khaabd8916 7 жыл бұрын
millions of likes ()
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
haha, thank you
@libvlog2264
@libvlog2264 7 жыл бұрын
hey the swift guy where u stay?
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
Denmark;)
@bellekiller
@bellekiller 7 жыл бұрын
it's like naming a function function....
@1TheSwiftGuy
@1TheSwiftGuy 7 жыл бұрын
haha, I dont quite remember the video, but I guess you are right:) I would give it a different name
How To Create A To Do List App In Xcode 8 (Swift 3.0)
14:58
The Swift Guy
Рет қаралды 91 М.
How To Pass Data Between View Controller (Swift 4 + Xcode 9.0)
6:51
Swift with Yash
Рет қаралды 12 М.
小丑揭穿坏人的阴谋 #小丑 #天使 #shorts
00:35
好人小丑
Рет қаралды 41 МЛН
When mom gets home, but you're in rollerblades.
00:40
Daniel LaBelle
Рет қаралды 133 МЛН
Passing Data between View Controllers (Swift 4)
12:38
TheCodex
Рет қаралды 71 М.
The Vim Experience
45:19
Bog
Рет қаралды 137 М.
You Won’t Believe What Excel’s Copilot Can Do! (new updates)
10:37
How To Use Multiple View Controllers In Xcode 8 (Swift 3.0)
15:33
The Swift Guy
Рет қаралды 107 М.
One CPU To Rule Them All - Ryzen 7 9800X3D Review
12:47
Linus Tech Tips
Рет қаралды 1 МЛН
The M4 Mac Mini is Incredible!
11:45
Marques Brownlee
Рет қаралды 1,4 МЛН
iOS Popup View Using Separate View Controller (Xcode 8, Swift 3)
14:23
How to Animate a Button Menu (iOS, Xcode 8, Swift 3)
20:02
Mark Moeykens
Рет қаралды 56 М.
How To Use Constraints And Size Classes In xCode 8
14:22
The Swift Guy
Рет қаралды 91 М.
How To Create An Audio Recorder In Xcode 8 (Swift 3) - Part 2
16:36
The Swift Guy
Рет қаралды 15 М.