Retrieving data from database to a different view controller - iphone

http://www.techotopia.com/index.php/An_Example_SQLite_based_iOS_4_iPhone_Application_%28Xcode_4%29
I have found this sqlite tutorial on google and it worked great for my requirement.
In this tutorial both adding and retrieving data are done on the same viewcontroller. but i want that 'save' method in the tutorial in one viewcontroller and 'find' method in the other.
And also someone tell me whether this tutorial is an effective way to save data or not.because this is the easiest tutorial I found so far.

You might also create a new class ,or use inheritance (upper class) call it for example "SqliteClass"
that have both the 'Save' and 'Find' method
then you can use any method in SqliteClass from any other class ,,
in case you don't want to use inheritance make sure that the methods in SqliteClass are "class" methods the one begins with "+" not"-"
I used both ways and they work just fine ..
Hope that helps :)

Yes, you can to that. you can have n number of view and can save data from any view controller.
check this tutorial.
http://www.icodeblog.com/2008/08/19/iphone-programming-tutorial-creating-a-todo-list-using-sqlite-part-1/

Related

Swift and Parse - PFQueryTableViewController loadingViewEnabled

Good day! I'm using Parse for my swift project, Specifically the PFQueryTableViewController but i want to change the loading view when i open the app. It doesn't look good in my background so i want to change its color and shadow. Also its UIActivityIndicatorView. Is it possible to change this things? Here is the Screenshot for it.
I tried searching for that method in ParseUI framework but i can't find it. I hope you can help me, Thanks!
Only the table controller is unique to Parse. The spinner is just a regular UI element. Thus, the iOS developer references are good places to look for this.
Try this link for the activity spinner:
This link shows information about the controller, which shows that it simply inherits from UITableViewController, and the cells/background can be styled accordingly.
In general, Parse tries to prefix its objects with PF.

How to pass information between views

I want to pass information like number between two views in navigation controller. But I don't know how.
Thanks
Another option might be using singletons if the "numbers" are just a synonym for your application model. Remember, you should use the MVC-concept!
http://cocoawithlove.com/2008/11/singletons-appdelegates-and-top-level.html
Try the SynthesizeSingleton.h macro if you want a tough solution!
You need to use delegates and protocols. Here is a site with an example http://iosdevelopertips.com/objective-c/the-basics-of-protocols-and-delegates.html

Trying to message a button from another class

I'm new to Objective-C so I may be doing this completely wrong, and if I am please correct me. I am trying to make a separate class in my iPhone app just for skinning buttons. My hope is that this will allow me to reuse as much code as possible but before I spend too much time on it, I would like to know if its possible/a good idea to send a message to a UI Control from another class, and if i can, how should I do it? right now im trying to pass the sender ID to my SkinTools class and message that but it doesn't look like it will allow me to message the layer object.
So, am I just completely off the wall here, or is this possible?
Consider looking into using the delegate pattern.
One could just use the addTarget:selector: method for this purpose. As target set the class you want to send the message to, as selector the method you want to call on the class.
You could add some iVars to your class, like id buttonTarget and SEL buttonSelector and create an initializer like -initButtonWithTarget:selector: to set these values on initialization.
It turns out categories was the answer I needed, then I can just add a skin method to each control I use. I can even put them all in the same file to make it easy to get to.

What is the three20 method of passing objects between view controllers?

I have a basic RSS Reader I made from three20 tutorials using TTLauncherView as a menu to different feeds and TTTableViewController to show the feed list.
However, I am stuck at the point where from the feed list I click to view the feed item details. I use TTTableImageItem to display my feed items and I'm clueless as to how I am to use the URL variable in said TTTableImageItem to pass objects to the view controller showing the feed item.
I did some searching and I am lead to think that this cannot be done except via TTURLRequest, which leaves me even more confused.
Most of my code is adapted from IOSGuys tutorial, which uses a custom data source, data model and parser. I have tried making the data source and data model a singleton but to no avail and I'm unsure if that's even the best way to proceed for something as (presumably) simple as this.
Ideally I intend to pass the entire array of feed items with another argument for the index so that I can make use of UIPageControl to swipe between feeds when I'm at a more in-depth view.
Much help is appreciated! I have been spending too long looming around already!
The usual way of doing this is to have some sort of global singleton Data Manager class that manages the data models through Core Data, In-Memory Stores or other ways. Each model would have some sort of unique identifier. Doing it this way lends itself to a URL only stack needed to recover your navigation history without having to write state out to file in order to restore. You also can bring up any page in the app at any place with only a single URL. Using a URL scheme only then becomes trivial as you can do something like:
yourapp://blogs/jd82kd9
and have the blog view controller's init method contact the Data Manager for the blog with the unique identifier of jd82kd9
In your navigator's mappings, you would have something like this:
[map from:#"yourapp://blogs/(initWithBlogID:)") toViewController:[MyBlogViewController class]];
and then the initWithBlogID method would have the signature:
- (id)initWithBlogID:(NSString *)blogID;
see also Three20 : how to pass a class of objects between 2 views

Best practice for View-Routing in iPhone SDK

I've run into a little problem while developing a Core Data driven Quiz and be a bit confused about a best practice to solve my problem.
I have approximately five templates for the different questions, which will be loaded in case which question is displayed. So I check which template has question 1 and push the new question-template view into my navigation controller. Because its always the same code I want to write a function (I came from php) which gets the next question-id as argument and decide which template will be loaded and push the next view into the navigation-controller.
What is the best practice to solve this problem? Can I write a function with access to the navigation-controller, and my Core Data classes. And if yes where I have to create this function?
Okay I think I found an way but gets here another Error. I create a class called QuestionRouter and define an class method. I'll import this class into each viewController where it needed. The class method gets the correct template from Core Data without an problem. But now I wan't to load the correct view. For that I need to access the navigationController defined in my AppDelegate.
So how I can access the navigationController in my AppDelegate for another class?
Hope for an answer.
Mister-D