Different methods to display NSarray - iphone

I have an array which store highscore records, besides using tableview, is there another way i can display my array.

That's the best way, if you're using an NSArray as a datasource; if you don't need the users to interact with the data, you could use a UIScrollView, maybe, by adding a UILabel for every data row, though this seems clunky.
Your other option, and probably the best option, is to customize the look of the tableview, as shown in this tutorial.

Related

How can I create a UITableView with selectable options?

I'm looking to create a grouped style UITableView that allows a user to select different options (like shown below). I'm already able to setup the UITableView in a grouped style; my question is based on how I can add buttons, toggles and list options like shown below? Is it possible to make use of plist's to simplify the process somewhat?
Note: I'm not trying to create a 'settings' view, I want to allow users to create lots of different NSDictionaries and set values on each of them using the table setup described.
You should create your own UITableViewCell. This way you could add the desired UI items of your choice. You could use the Interface builder to create your custom cell. There are many good tutorials on the subject.
I do not see the need to use a property list for this, since it is rather simple to implement this.
This is a good example:
http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html
You should look a this library : http://www.inappsettingskit.com/
Other exist but I don't remember the name. Or you can define your own data structure in plist, and associate with UITableViewCell type. But this will require a lot more coding.
For adding a UISwitch to a UITableViewCell, you may want to have a look at the answer to this question on SO.
your answere lies in the delegate method didselectrowatindexpath. if you want to add options to the individual cells, you'll need either a custom uitableviewcell or set things in generic uitableviewcell accordingly. also, a notable mention would be to look into tableView:accessoryButtonTappedForRowWithIndexPath:
next you should use the plist as follows to read it:
NSString* plistPath = [[NSBundle mainBundle] pathForResource:#"league" ofType:#"plist"];
contentArray = [NSArray arrayWithContentsOfFile:plistPath];
This could be called in your [uitableview cellForRowAtIndexpath:] delegate method and parse it accordingly
cheers~
fy

How to store information in a detailed view from a TableView

I have a bunch of information from a few views (stored in a singleton) that I collected from the user, now all displayed in one confirmation view. How do I take this information and create a new UITableViewCell that one can click on to see the entered information.
And, although this comes later, how do I make sure this data is stored between sessions and never deleted unless done so by the user.
Thanks for the help.
Showing the data in a UITableView is quite trivial, and I suggest you check out the UITableView Class Reference, UITableViewDelegate and UITableViewDataSource protocols to find out how you can do that.
For the storage of the data, one of the ways to do so is by using the NSUserDefaults.
Once you have stored the user's data, you can access the NSUserDefaults from a different view without having to pass any objects between those views / controllers.
Generally you'll want to use properties and delegates to pass data between views.
As far as persisting data, for light-weight data (like preferences) use NSUserDefaults. For more complex data, use Core Data.

Keeping data in a UIViewController, even after go to a TablevViewController and come back?

I have a UIViewController with some UITextFields in it which holds username and other details. And i need to go to another view, which is a UITableView which holds the list of countries to user to choose and get back to the UIViewController again, when user picks one.
What my problem is i will lose all my data mentioned previously in the UIViewControl, when get back from UITableView. I can use application's delegate to store data when go to UITableView and load them back when UIViewController is loaded again.
I was wondering, whether is there a way to achieve my goal, other than this approach? I have to use number of variables in the delegate to store these data as there are many.
Can anyone help me out with an idea please???
I dont think.But I think you are reloading the table in viewWillAppear.Thats why ur older values are not remaining

Iphone, user created labels?

Usually When i want a object to be accesed by many different event calls i just declare it in the h file.
However im making a app where i need to allow the user to create UILabels and drag and drop them where they want. So i have the code to make the labels and a alertview where they change the text.
-(IBAction)AddText{
UITextField *TextView;
TextView = [[UITextView alloc] initWithFrame:CGRectMake(40.0, 40.0, 40, 40)];
[self.view addSubview:TextView];
Which works however i need the user to be able to create many textviews which each have a unique name and a way i can reference them later such as TextView.text, doing it this way always creates a object named TextView and i can only reference it from his event, otherwise its undeclared.
Im really stuck at how i would go about doing this if anyone could help it would be great!,
Thanks
You could think about adding the newly created label to a NSMutableArray or, better, to a NSMutableDictionary. This latter solution gives you the possibility of creating a dictionary in which each label can be referred to using a string key. If you put such a dictionary in your .h file you'll be fine, I think.
How about creating an NSMutableArray of NSDictionary items. The dictionary items could have a reference to the label as well as things like name, and other relevant meta information.
You can add the UITextViews to a collection of some sort, depending on how you want to retrieve them later.

Using CoreData outside of a TableView on the iPhone

My application has a simple data model with 70 read-only records grouped into six categories. Currently the persistent data is stored in an XML file which I parse on application launch, and create objects for each record which are stored in an NSMutableArray.
I then populate a UIPickerView from the objects stored in the array, and when the user selects a row in the picker, display content pulled from the same objects.
Using CoreData and SQLite would use much less code, but it seems to be designed to work with UITableViews exclusively.
Has anyone used CoreData to fetch records outside of the UITableView interface?
Thanks
jk
Core Data is not designed to work with UITableViews only. Although it's really easy to Core Data with the NSFetchedResultsController to populate a table view you can still do all the fetches you want on your an.
Just make your own NSFetchRequests to get the data you want. From the list of objects, particular objects or just single values you can use this date for whatever purpose intended.
I put my custom Core Data methods into the application delegate, where they can be called from any class. To do this, I add a #define as follows:
#define UIAppDelegate ((MyAppDelegate *) [[UIApplication sharedApplication] delegate])
I can then call my methods like so:
[UIAppDelegate fetchBooks:managedObjectContext];
A UITableView is not required for any of this.