Load String automatically on launch - iphone

Hey everyone, I have a little issue that I can't seem to figure out. What Im trying to do is have pre-saved values automatically put into the textfields on launch. Right now, I have the user filling out the fields, then pressing a save button. At next launch, the user needs to press the load button, how do i eliminate that load button?

In your Save button action, do this ...
[[NSUserDefaults standardUserDefaults] setObject:myKey1TextField.text forKey:#"key1"];
... and in your viewWillAppear method do this ...
myKey1TextField.text = [[NSUserDefaults standardUserDefaults] stringForKey:#"key1"];
... viewWillAppear is not the only place where you can place it. It depends on how frequently these data are changed, if they can be changed in background, etc.

Look at the NSUserDefaults API.
Basically you save your content with key/pair, so when your app is launched you just retrieve these values.

I did something like this the other day but i am using core data. I just stored the previous value my core data file and read it back the next time the app launches, lot of mucking around if you don't have core data already but just putting it out there for anyone with a similar problem

Related

How can I save a website in Cocoa Touch and store it in an array?

I am just building an app for my first time. I've created it so that I open it and it opens web view and I have a button called "Save" (so it's just a web view inside the app with a little button below it). I would like to be able to save a website when I visit it. It doesn't need to label the save or anything, I just want it to save and I can click another button called "sites" and it will display my list of saved websites.
You will have to decide on some kind of storage method. A simple one would be create an NSMutableArray of the sites. Depending on the needs of the application, you could change this to something different. Then, saving the site is as simple as inserting an object that represents the page (maybe an NSURL or an NSString with the URL). The question Get current URL of UIWebView discusses several ways of getting a URL from a webview. You can then decide on a way to display the list of saved sites. Once a site is selected, you just have to pass it back to the webview.

iPhone Restkit - Error at data loaded after back button pressed

i found like my question answers, but my app stil not working.
I push view to controller-2 from controller-1. In controller-2 Restkit loading data, but not loaded, i quickly press back button to controller-1 and after few seconds app is crushing (Restkit loaded data).
I using ARC.
Please help me fix this problem. Thank you.
This happens because RestKit continues the network activity and then cannot find your controller since it has been closed and its location in memory deallocated. I'd suggest either adding some logic to prevent the user from hitting back while RestKit is loading data, or canceling all pending network requests like mja suggested.
One way to do this is to add the following line to viewDidUnload:
[[[[RKObjectManager sharedManager] client] requestQueue] cancelRequestsWithDelegate:self];

Serialization with objective-c

I'm doing a iphone application and when the user quit the application and return in the application later, I want he return at the same place in the application before he quit. How I do this? Is it serialization?
thanks
Alex
It's a little different than serialization. What you want to do is save the app details in NSUserDefaults. For example, if you have a tab view, save the index of the last tab used in the user defaults.
If you have a table view, you can use serialization to save the actual information in the table to present back to the user when they start the app again.

How to limit parsing and display the previously parsed contents in iPhone?

I am new to iPhone development. I am parsing a URL and displayed its content in the table. On clicking a row it plays a video. When I click a done button, I once again call the tableview.
When I call the table view it parses the URL once again to display the contents. I want to limit the parsing for 1 time and for the next time I want to display the contents which are parsed at the first time. How can I achieve it?
Not to sound condescending, but, don't do that? When the results are first requested, parse them and store the parsed results. From there on out, only return those.
Without more information about your problem, it seems that trivial.

dynamically add Items to TTLauncher

in my app i got a TTLauncher Object with some TTLauncherItems in it.
Now i want to add some Items dynamically inside my App by pressing a button.
Is there a simple way to do that or do i have to create my own methods?
In the original facebook application there is already something like that implemented. (You can add your Friends to the Launcher)
If not, what would be the best thing to do something like that? Store all "extra items" in a plist oder even in a database and query them, each time TTLauncher object is initialized?
Thanks for help :)
so i finally used a simple plist to store my items.
every time my items get new arranged or an item gets added, i update my plist with this new data. when the view gets initialised, i building all this items out of my plist.
a better way would be to store it in a database i think, but for me, a plist is enough.
I have ran out in the same issue as I told you earlier: so
You store your additional icons in a table.
on LoadView()
you try to use a dynamic array like this:
_launcherView.pages = [NSArray arrayWithObjects: dynamicArr1];
Where your dynamic Array is filled like this:
caching of images of each icon here:
http://groups.google.com/group/three20/msg/66ec114401af3b06
[dynamicArr1 insertObject:[[[TTLauncherItem alloc] initWithTitle:name
image:name
URL:url canDelete:YES] autorelease] atIndex:i];
Let me know if that's what you were looking for.