Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Timerez

macrumors newbie
Original poster
Jun 4, 2014
19
0
I am new to Swift and developing app. Swift has something I am not familiar with and it's possibly ARC, or something similar.

I've designed an app and I have couple of tab bar items to switch view per view controller. What I'd like to do is whenever one of those tab is pressed, the view is "reset" to original - like one of tabbed view has pagecontrol and it stays on that specific page when returned rather than back to page 1 - and not left as it is when you switch views. Does ARC take part in this or is it different concept?

If It's ARC, can you explain a bit more about ARC? I read a bit on it in swift ebook from itune but I don't really understand... But again, I never learned how to do memory management before and maybe it hasn't "click" just yet.

But if it's not ARC, can anyone point me in right direction on this?

Thanks
 
Last edited:
Ok, 1st ARC is Automatic Reference Counting. It's designed to replace manual referencing counting.

Manual referencing counting is where you keep track manually of the objects so that you can remove them from memory or free up the memory.

It's like you personally keeping track of things you need and don't need. When you determine that you don't need something, you throw it into the trash.

Some systems do this as part of a garbage collection system, this hasn't always worked well on small systems with very limited memory because of the extra processing time it takes causes the system to slow down.

ARC makes this so the "system" does this for you.

With ObjectiveC iOS development, ARC is the way to go since the last few years or so. My guess is that is just as true with Swift, as Swift is designed to be less complex.

It's not something that you need to think too much about, you just let the system do that for you.

I don't think you need to worry about it when setting a tab-view.
 
I don't think you need to worry about it when setting a tab-view.

Okay then it's not working too well :p

Because I've ran app on iPad (instead of simulator) and those tabbed items still do not revert back to original view/setting when switching controllers/pages and back. A bug? Or...?
 
Because I've ran app on iPad (instead of simulator) and those tabbed items still do not revert back to original view/setting when switching controllers/pages and back. A bug? Or...?

That is not a bug. That is working the way it was designed to work. Users would probably be rather annoyed if their views were reset whenever they were tabbing between them. If you want this functionality, I believe you will have to code it that way.
 
That is not a bug. That is working the way it was designed to work. Users would probably be rather annoyed if their views were reset whenever they were tabbing between them. If you want this functionality, I believe you will have to code it that way.

Oh, I see... I was not sure if it was just me. Thank you guys for clarifying! I appreciate your times. :)
 
I've designed an app and I have couple of tab bar items to switch view per view controller. What I'd like to do is whenever one of those tab is pressed, the view is "reset" to original - like one of tabbed view has pagecontrol and it stays on that specific page when returned rather than back to page 1 - and not left as it is when you switch views. Does ARC take part in this or is it different concept?

ARC has nothing to do with what you describe. If you want to restore original states, you have to write code that does that. ARC is completely irrelevant for this.


What you describe is similar in concept to the initial state of <input> elements in an HTML form. For example, you can specify a checkbox with an initial state that's checked:
Code:
<input type='checkbox' name='c0' value='0' checked>
When the form is reset with an input element like this: <input type='reset' value='Reset'>, then the original 'checked' state will be restored. Any checkbox that lacks an initial 'checked' state will be restored to unchecked. Other input element types behave in a way specific to their type when reset.

As stated above, ARC has nothing to do with this. If you want that behavior, you have to code it. UI elements have an initial state, but I don't know any way to restore or reset to that state without writing code to accomplish it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.