save a view with NSUserDefaults {iPhone SDK} - iphone

i try to use NSUserDefault or something like this , to save a specific view after quit from application and when user lunch application again load from that view ... but i dont know how!

I would suggest you have a look at the NSCoder class and its related components. The API is specifically built for arching and dearchiving Objective-C class instances.

Related

application flow in iphone program

I am making a application for the iphone and i am using window based application and i am doing this:
#importing all UIViewController class in the appDelegate class.
creating the object for accessing the variables and function and I am controlling all
action,event and controls from the appDelegate class.
I want to ask that is this right approach. I dont want to use view based application, I want to use UIViewController class just only controllers display.
If this is not a good approach for making the application tell me the good process for doing this.
I suggest you take a look at this:
http://www.icodeblog.com/2011/10/11/back-to-basics-an-introduction-to-view-controllers/
You should also read up on the iPhone-programming-basics, you will find a lot of nice tutorials and articles with a quick Google-search for "iPhone programming".
You could just create a singleton that holds the data and methods you want to share and access it from any view controller you want. Conceptually, it's not much different then what you are doing with the appDelegate class but it is better so that you don't clutter up the app delegate.

How to get/set the rootViewController?

Now,I gonna Develop an App ,which wants to switch from many different Views irregularly,also the views need to load large resources,AKA,it's hard to manage memory.Are there any good solustion?
PS:I created a ViewController as RootViewController,and When a button was Touch,run the code as
"ViewController=newController"
.The problem came,The new View loaded wrong way,it rotate so that couldn't show in a correct way.
I google for the solution,some one said ,I should replace the rootViewController,just like that,
[UIApplication sharedApplication].delegate.window.rootViewController=newController;
But I can't get/set the rootViewController in other class though it's a singleton.
Why not having a class that handles all the view switches ?
This article describes an architecture that might be helpfull: http://www.mikeziray.com/2010/01/27/handling-your-initial-view-controllers-for-iphone/comment-page-1/#comment-607

iPhone - Write in app delegate

i have to write some code that initialize my data app. This must be made before the app the app is loaded. In my opinion the best way is to write this code in app delegate. Am i right?
p.s. : the code download some xml from the net and parse a lot of data and put in core data.
Depending on the exact context you can also implement a + (void)initialize method in your class.
YES friend if you write on applicationDidFinishLaunching method in appDelegate ..then webservice get called before the app launch and you have all that data when you start your application . for that you need to set connection by AsiHTTP connection DElegate and parse using NSXmlParserDelegate..
Yes , its right to call xml parsing in appdelegate so that you had data , before your app first view loads.

Declaring MutableArray of Custome class in to AppDelegate of iPhone application

I am working on iPhone application in which i have more than 20 class and i am declaring that classes NSMutableArray into my application's app Delegate file, and accessing them from my different views.
All NSMutableArray are filled by XMLParsar requesting from server.
My application is getting slow in process, is it because i have declare in app delegate file?
or is that proper way to implement?(declaring all objects into app delegate file.)
Thanks.
Nope, you should try to keep your application delegate as simple as possible. There are other ways how to handle shared data - singleton for example. Here's an example: http://www.johnwordsworth.com/2010/04/iphone-code-snippet-the-singleton-pattern/ There also other methods too, depends on your task and application.

how to parsing the xml and showing the table

Hi friends i tried to parse the xml and show in table view .
but without use of appDelegate object how can we .
i have seen in many site that was started from application beginning .
but i want to know if i need to parse and show in different view controller which is not root
view controller and also should not use the application delegate?
please any genius
So it sounds like you have a data model saved as XML somewhere, and when your application loads, you want to parse it and keep the model in memory.
In my experience, the application delegate is actually the place to keep stuff like this. Since it's something that both the application delegate, and the random UIViewController need to know about, the app delegate is a good place to keep it.
Once you've loaded your model using the NSXMLParser or your preferred loader, you can (in your UIViewController) use something like:
MyModel *model = ((MyAppDelegate *)[[UIApplication sharedApplication] delegate]).myModel;