Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Justin Rich
Justin Rich
19,556 Points

State Management In Swift/iOS

I've started programming in Swift, my main experience has been in web dev w React.js. I'm wondering how state is managed in iOS app development? Is there a way to manage state both locally (say in a component) or across your entire program? I'm wondering this as it's a feature of React.js I love and would like to carry on into my iOS work. Thanks.

Justin

2 Answers

Alex Stevens
PLUS
Alex Stevens
Courses Plus Student 9,174 Points

Hi Justin, Great Question! Well first of all I think iOS Swift is not alike React.js, Vue.js or Angular. It's a kind of server side language in nature like PHP or Java. However, we can maintain state/data manually in class members, passing them to other viewcontrollers by hooking through segues, and retrieving data directly from local database/storage such as NSUserDefaults, CoreData or Realm etc.

Caleb Kleveter
MOD
Caleb Kleveter
Treehouse Moderator 37,862 Points

With standard iOS development, you don't really work with state in the same way you do with React/Vue. You can do it with RxSwift, though I have never used it and TH doesn't have any courses. Might be worth looking into.