Using the AppDelegate? - ios

I regularly listen and watch the Stanford University iOS Programming Courses (CS193p) that are delivered by Paul Hegarty.
Even though these sessions move at a quick rate, they have proved valuable when it comes to learning the various topics covered.
In the latest series (Winter 2013) and in particular Lecture 2, Paul has made the comment disregard both the AppDelegate Interface & Implementation files created by XCode 4 when first creating a project and basically design your own Model.
Why do this if you have to redesign to include ‘window’ objects and the various application protocols when you can use the ones already provided to you in AppDelegate?

I think that you misunderstood the suggestion to "disregard the app delegate." Considering the application delegate's central location, it sometimes tends to become a "dumping ground" for everything shared. Need a flag or two? Throw it into the app delegate! Need a counter? No problem, put it into the app delegate! This is precisely the thing you should not be doing: storing the application state is something the model does; keep the app delegate out of it.
I do not think that the advice is to throw away the generated code for the app delegate, though: you need it to manage your application's lifecycle. But managing the lifecycle is the only thing for which you should be using your app delegate: your model classes need to be cleanly separated from it.

Related

iOS background tasks synhronization app flow

I'm programming in iOS not so long. I was mainly programming UI related stuff like animations, custom UIControls etc.
I need in my new app to:
Display loading activity indicator and in the same time:
load some remote data from server parse them and store in local core data
load some data from local core data
get user position from location service
After this I have all data needed to display next view controller and dismiss loading indicator.
Question is how can I do this all? I need to support iOS9, iOS10, 11, 12. I understand that this needs to be done in background threads and then I need to merge all data from each task and switch to next view controller. I can't use any external libraries like rx-swift or promise-kit. Maybe there is any experienced iOS developer who can give me some main guidelines how to approach to this kind of application flows? I can imagine there is a lot of ways I can do it some of them are better and some of them are worse. Any guidelines would be very helpful for me. Thanks.
It's a very complex question and as you said it's possible to solve all this problems in several ways. But for sure i can give you some core-hints about which steps is better to follow:
Run in a separate thread the management of all stuff regarding to the Network communication. Maybe you can run it on a separate queue using the class DispatchQueue(). Once you received the data, in the same thread, maybe you can directly convert these information and store them inside a CoreData database.
To store into CoreData you need at first to know how it works, so basically search for some really easy tutorial about how to create from zero your first database inside XCode. After you have been able to run and execute a very simple one you will be able to pass to the second step and so try to integrate it with the data you have previously downloaded from the network. Here a good article for you: https://www.raywenderlich.com/7569-getting-started-with-core-data-tutorial .
To get the location is a separate field of study, because you have to study which background modes are allowed in iOS (And actually are allowed just a few). After that you will need to figure out in which category of background-location application your software belongs. After that you have to dig deep and discover how protocol and delegates works inside Swift/Objective-C in order to properly manage the last location value retrieved by the sensors. Here is a good article for you: https://www.raywenderlich.com/5247-core-location-tutorial-for-ios-tracking-visited-locations.
At the end when you interconnected all this flows you can think about how to display the loading indicator. Basically you need to drag and drop it from the tools into the storyboard, interconnect it by using the IBAction or IBOutlet, depending on when you wanna show it and in which specific case. And then use the relative method startAnimating or stopAnimating in the right code flow (It really depends on how you have structured all the previous bullet points).
Since your question was very general and it includes a lot of sub-steps, basically it really needs to be thorough studied and analysed.
I've tried to sum up as much as possible the most important bullet points. I hope the links i suggested to you will help a little bit. Good luck.

Binding technology to use for iOS app

I am a novice iOS app developer. Basically i need to listen for any change in the UI (e.g., doing something on text change in textviewUI), and update UI to reflect any model change. I was looking into different technologies available for binding and am bit overwhelmed.
I know this is very subjective, but i would like to hear your suggestions on it (for swift and objective c both)
Also any pointers to the best practices would be really helpful.
Welcome to iOS! Cocoa (Touch for iOS)- Apple's framework- has some design patterns you will want to learn...
These include delegation and target/ action. Quickly summarized: delegation is handing some responsibilities off to an object that can take care of them. This provides methods you can use to get stuff (like changes) to that object. Read this link to learn more about delegates: https://useyourloaf.com/blog/quick-guide-to-swift-delegates/
Now, back to the text field example. A handy method in the UITextField delegate called textField(_:shouldChangeCharactersIn:replacementString:) will be called whenever the text field is going to change. As for target/ action, that's google-able. Is that a word? As for any pointers, learn MVC. Have fun!

Resuming the application from where the user left unexpectedly or before. [duplicate]

I would like to ask some suggestion about how to restore a viewControllers state.
Like in the app called "Pic Collage" when you create a card and save it and later restore it.
If you really want to learn about state preservation, see WWDC 2012 video, Saving and Restoring Application State on iOS.
But, it's also just as likely that the app in question is simply saving the model data (the object model that represents this card) in persistent storage, and when the app re-starts, it simply loads that model data again. There are a whole bunch of possible technologies for persistent storage ranging from Core Data (robust, but a little complicated) to plists (simple, but less sophisticated). There are tons other options (archives and serialization, SQLite, JSON, etc.), but I'd rather not cloud the issue further.
I'd suggest you familiarize yourself with some of these technologies, work through a few demonstrations, and come back if you have additional questions. But this question is too broad to get into specific answers at this point.
If you are supporting iOS 6 and above, take a look at State Preservation and Restoration. Even if you have to support older versions of iOS the documentation will guide you on when and how restoration can be achieved and the things you need to consider.

iOS Jailbroken devices development: How to dump method calls

I am pretty new to development for iOS devices with jailbreak. From what I am reading I understand that to be able to do all the cool things which you can't do on non-jailbroken phones you have to hook up to a given class and override some of its behaviour. Since there is no documentation how a developer tracks to which class exactly he should hook?
I imagine that for instance if I wanted to have my app respond to a given event such as phone boot, call hang up or user clicking on an icon I would manually generate the given event and see what invocations have been made. Is this the proper way to track where you should hook your code and if yes how is it done.
Note I am not interested in exactly those events mentioned above I am more interested the approach in general.
There are several approaches:
Disassemble binaries
You can disassemble a binary or just dump classes with something like class-dump.
So, you can see the whole hierarhy of classes.
Find dumped classes
Most of major iOS subsystems were dissasembled by somebody already. You can find quite a lot of useful stuff.
As example. Google search "Springboard headers" got this
Dump classes in a runtime.
Look at this question for explanation: List selectors for Objective-C object

How to make an iOS app start where it left off

I'm making an iOS app through UIStoryboard mode and I wanted to know if there was a way to add something so when the user leaves the application, it'll continue where the user left off next time he launches the application.
By the way, I'm making a simple UIStoryboard application like I mentioned earlier that only has simple pages.
Thanks!
Check out this section in the documentation where Apple briefly touches on this topic.
Preserving the State of Your App’s User Interface
I think this is the general idea of how you would do this, the Three20 framework does this by using URLs, you may attempt to adopt this design as well. This is not to say you should USE Three20 but you can gain some ideas from seeing how they solve this problem.
Persistence in Three20 Framework

Resources