I am trying to set an array in another view controller, named BillTrackerViewController, to the values of an NSMutableArray called billtrackertablevalues, located in the main class, MainViewController. I intend to use the array in BillTrackerViewController as data for the UITableView there. However, when I try to set the value of that array, table_items, and segue, the table doesn't show anything. However, the value of billtrackertablevalues is properly filled, and is NOT null.
Here is my code for MainViewController:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:#"toBillTracker"]) {
PFQuery *query = [PFQuery queryWithClassName:#"Resolution"];
[query whereKey:#"event" equalTo:event_name_label.text];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
for (PFObject *object in objects) {
[billtrackertablevalues addObject:[NSString stringWithFormat:#"%#\nPro: %#\nCon: %#\nResult: %#",[object objectForKey:#"resolution_name"], [object objectForKey:#"resolution_pro_speaker"], [object objectForKey:#"resolution_con_speaker"], [object objectForKey:#"resolution_result_id"]]];
}
NSLog(#"%#", billtrackertablevalues);
} else {
NSLog(#"Error: %# %#", error, [error userInfo]);
}
}];
BillTrackerViewController *controller=(BillTrackerViewController *)segue.destinationViewController;
controller.table_items = [[NSMutableArray alloc] init];
controller.table_items = billtrackertablevalues;
}
}
And here is my code for BillTrackerViewController:
#import "BillTrackerViewController.h"
#import "Parse/Parse.h"
#interface BillTrackerViewController ()
#end
#implementation BillTrackerViewController
#synthesize billView;
#synthesize refreshButton;
#synthesize table_items;
- (void)viewDidLoad
{
[super viewDidLoad];
[billView reloadData];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) { }
return self;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [table_items count];
}
- (UITableViewCell *)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"MainCell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"MainCell"];
}
NSString *cellText = table_items[indexPath.row];
cell.textLabel.text = cellText;
return cell;
}
#end
Once again, the table on BillTrackerViewController doesn't load values, but my initial array, billtrackertablevalues, is filled.
Thanks in advance, guys!
I think you need to move the lines instantiating controller, and setting its property to inside the block method:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:#"toBillTracker"]) {
PFQuery *query = [PFQuery queryWithClassName:#"Resolution"];
[query whereKey:#"event" equalTo:event_name_label.text];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
for (PFObject *object in objects) {
[billtrackertablevalues addObject:[NSString stringWithFormat:#"%#\nPro: %#\nCon: %#\nResult: %#",[object objectForKey:#"resolution_name"], [object objectForKey:#"resolution_pro_speaker"], [object objectForKey:#"resolution_con_speaker"], [object objectForKey:#"resolution_result_id"]]];
}
NSLog(#"%#", billtrackertablevalues);
BillTrackerViewController *controller=(BillTrackerViewController *)segue.destinationViewController;
controller.table_items = billtrackertablevalues;
} else {
NSLog(#"Error: %# %#", error, [error userInfo]);
}
}];
}
}
After Edit:
There is still a timing issue because the segue happens before the block returns, so you should override the setter for table_items in the BillTrackerViewController. The segue will still occur first (you might want to put a spinner in your view so the user knows something is happening), and then when the block finishes, the setter will be called:
-(void)setTable_items:(NSString *)table_items {
_table_items = table_items;
//update your table here.
}
How about this:
controller.table_items = [[NSMutableArray alloc] initWithArray:billtrackertablevalues];
Also the problem might be in the BillTrackerViewController itself
Related
This question has been successfully answered; thank you to jsksma2.
I cannot get my data to fill the rows in my TableView, even though I get the data back properly and can hard-code the tableview to display a static amount of dummy text. I have a hunch my issue relates to initWithStyle vs initWithCoder for subclassed UITableViewCells.
In a subclass of UITableViewController called "GiveItemsTableViewC", during viewDidLoad I am querying Parse for objects each called "PFGiveItem". I get these back and add each one to a global variable, a mutable array called "myGiveItems". I log these, and I get what I am looking for, so that part is working.
GiveItemsTableViewController
- (void)viewDidLoad
{
[super viewDidLoad];
PFQuery *query = [PFQuery queryWithClassName:#"giveItem"];
[query whereKey:#"giver" equalTo:[PFUser currentUser]];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
self.myGiveItems = [[NSMutableArray alloc]init];
for (PFObject *object in objects) {
PFGiveItem *newGiveItem = [[PFGiveItem alloc]init];
newGiveItem.giveItemName = object[#"giveItemTitle"];
newGiveItem.giveItemImage = object[#"giveItemPhoto"];
[self.myGiveItems addObject:newGiveItem];
}
} else {
// Log details of the failure
NSLog(#"Error: %# %#", error, [error userInfo]);
}
}];
}
Now I am trying to load each one of these giveItems into a TableView object, using custom TableViewCells each called "GiveItemCell."
GiveItemCell.m
#implementation JFGiveItemCell
#synthesize giveItemImageView = _giveItemImageView;
#synthesize giveItemLabel = _giveItemLabel;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
Back in the table view controller, I return one section for the table view.
And when I include a static number for the rowsInSection, I can output test values to each cell. If I execute the code below, I will get a tableView with cells with the label of "Test", as per the upcoming cellForRowAtIndexPath method. So it works with that test, but obviously I'm looking to dynamically load the proper information.
GiveItemsTableViewController
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 4;
}
- (JFGiveItemCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = #"Cell";
JFGiveItemCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil){
cell = [[JFGiveItemCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}
// PFGiveItem *giveItem = self.myGiveItems[indexPath.row];
// cell.giveItemLabel.text = giveItem.giveItemName;
cell.giveItemLabel.text = #"Test";
return cell;
}
It looks like you're forgetting to call [tableView reloadData] in the callback of your block method:
- (void)viewDidLoad
{
[super viewDidLoad];
PFQuery *query = [PFQuery queryWithClassName:#"giveItem"];
[query whereKey:#"giver" equalTo:[PFUser currentUser]];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
self.myGiveItems = [[NSMutableArray alloc]init];
for (PFObject *object in objects) {
PFGiveItem *newGiveItem = [[PFGiveItem alloc]init];
newGiveItem.giveItemName = object[#"giveItemTitle"];
newGiveItem.giveItemImage = object[#"giveItemPhoto"];
[self.myGiveItems addObject:newGiveItem];
}
[self.tableView reloadData];
} else {
// Log details of the failure
NSLog(#"Error: %# %#", error, [error userInfo]);
}
}];
}
Also, I second #CrimsonChris in saying that you need to set your dataSource methods properly:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.myGiveItems.count
}
There are a couple of problems...
Your numberOfRowsInSection should return the size of your myGiveItems array.
You need to tell your table view to reload when you finish loading your items asynchronously.
You don't need to implement number of sections, it defaults to 1.
I want to add some non editable text(it`s some description of toys in my app) via parse and I am stuck with the code.
This part (I think) I should change, but don`t know how.
Thanks
I`ve got it already like this
- (void) retrieveFromParse {
PFQuery *retrieveColors = [PFQuery queryWithClassName:#"Hracky1"];
[retrieveColors findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
colorsArray= [[NSArray alloc] initWithArray:objects];
}
[colorsTable reloadData];
}];
[self.colorsTable reloadData];
[self.refreshControl endRefreshing];
}
This is fully TableViewcontroller.m
#import "TableViewController.h"
#import "CustomCell.h"
#interface TableViewController (){
}
#end
#implementation TableViewController
#synthesize colorsTable;
- (void) retrieveFromParse {
PFQuery *retrieveColors = [PFQuery queryWithClassName:#"Hracky1"];
[retrieveColors findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
colorsArray= [[NSArray alloc] initWithArray:objects];
}
[colorsTable reloadData];
}];
[self.colorsTable reloadData];
[self.refreshControl endRefreshing];
}
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self performSelector:#selector(retrieveFromParse)];
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
self.refreshControl = refreshControl;
[refreshControl addTarget:self action:#selector(retrieveFromParse)
forControlEvents:UIControlEventValueChanged];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return colorsArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"colorsCell";
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
PFObject *tempObject = [colorsArray objectAtIndex:indexPath.row];
[cell.imageview setFile: [tempObject objectForKey:#"ImageURL"]];
[cell.imageview loadInBackground];
cell.cellTitle.text = [tempObject objectForKey:#"cellTitle"];
cell.cellDescript.text = [tempObject objectForKey:#"cellDescript"];
return cell;
}
#end
DetailViewController.m
#import "DetailViewController.h"
#import "Parse/Parse.h"
#interface DetailViewController ()
#end
#implementation DetailViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
-(void)parseview
{
NSString *showText = _textdescript.text;
PFObject *addValues= [PFObject objectWithClassName:#"Hracky1"];
[addValues setObject: showText forKey:#"TextView"];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self performSelector:#selector(parseview)];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
DetailViewController.h
> #import <UIKit/UIKit.h>
>
> #interface DetailViewController : UIViewController
> <UITextViewDelegate>
>
> #property (nonatomic, strong) IBOutlet UITextView *textdescript; #end
Add a property to the second view controller. Set it when preparing the segue or creating the instance with the identifier.
This code:
- (void)parseview
{
NSString *showText = _textdescript.text;
PFObject *addValues= [PFObject objectWithClassName:#"Hracky1"];
[addValues setObject: showText forKey:#"TextView"];
}
is creating a new empty parse object and setting some text into it. The text is probably nil or #"" because you have only just loaded the view when this happens (though you may have some default text in the XIB).
Most likely that you should be doing is getting an object back from Parse and interrogating it to get the text, then set that onto the view:
PFQuery *query = [PFQuery queryWithClassName:#"Hracky1"];
PFObject *object = [query getFirstObject]; // synchronous request, not ideal, look at getFirstObjectInBackgroundWithBlock
_textdescript.text = [object valueForKey:#"TextView"];
Assuming that you have a class Hracky1 defined in Parse and that it has a string variable named TextView.
When I run the following code, nothing appears on my UITableView. I created a global NSMutableArray for storing the results of a query on Parse, but I can't manage to use that array to load the cells on the UITableView.
Thanks!
#import "ViewController.h"
#import "MenuViewController.h"
#import "Parse/Parse.h"
#interface ViewController ()
#end
#implementation ViewController {
CLLocationManager *locationManager;
}
#synthesize eventTableView;
#synthesize eventTableViewCell;
- (void)viewDidLoad
{
[super viewDidLoad];
[self loadEvents];
}
- (void) loadEvents
{
eventNames = [[NSMutableArray alloc] init];
PFQuery *event_query = [PFQuery queryWithClassName:#"Event"];
[event_query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
NSLog(#"Successfully retrieved %lu scores.", (unsigned long)objects.count);
for (PFObject *object in objects) {
[eventNames addObject:[object objectForKey:#"event_name"]];
NSLog(#"%#", [object objectForKey:#"event_name"]);
NSLog(#"%lu", (unsigned long)eventNames.count);
}
} else {
NSLog(#"Error: %# %#", error, [error userInfo]);
}
}];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [eventNames count];
}
- (UITableViewCell *)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"MainCell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"MainCell"];
}
NSString *cellText = [NSString stringWithFormat:#"%#",eventNames[indexPath.row]];
NSLog(#"%#", eventNames[indexPath.row]);
cell.textLabel.text = cellText;
return cell;
}
#end
Copy and paste the following loadEvents method
- (void) loadEvents
{
eventNames = [[NSMutableArray alloc] init];
PFQuery *event_query = [PFQuery queryWithClassName:#"Event"];
[event_query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
NSLog(#"Successfully retrieved %lu scores.", (unsigned long)objects.count);
for (PFObject *object in objects) {
[eventNames addObject:[object objectForKey:#"event_name"]];
NSLog(#"%#", [object objectForKey:#"event_name"]);
NSLog(#"%lu", (unsigned long)eventNames.count);
}
[eventTableView reloadData];
} else {
NSLog(#"Error: %# %#", error, [error userInfo]);
}
}];
}
Every time you asynchronously fetch data for table view, you have to reload the whole table or the changed sections.
I'm guessing that the result from findObjectsInBackground returned after the tableview has already displayed. Did the NSLog print out the results that you expected?
One thing to try is to add a
[eventTableView reloadData];
after the for loop , which will tell the tableview to reload the data again.
I am trying to set an array in another view controller, named BillTrackerViewController, to the values of an NSMutableArray called billtrackertablevalues, located in the main class, MainViewController. I intend to use the array in BillTrackerViewController as data for the UITableView there. However, when I try to set the value of that array, table_items, and segue, the table doesn't show anything. However, the value of billtrackertablevalues is properly filled, and is NOT null.
Here is my code for MainViewController:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:#"toBillTracker"]) {
PFQuery *query = [PFQuery queryWithClassName:#"Resolution"];
[query whereKey:#"event" equalTo:event_name_label.text];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
for (PFObject *object in objects) {
[billtrackertablevalues addObject:[NSString stringWithFormat:#"%#\nPro: %#\nCon: %#\nResult: %#",[object objectForKey:#"resolution_name"], [object objectForKey:#"resolution_pro_speaker"], [object objectForKey:#"resolution_con_speaker"], [object objectForKey:#"resolution_result_id"]]];
}
NSLog(#"%#", billtrackertablevalues);
BillTrackerViewController *controller=(BillTrackerViewController *)segue.destinationViewController;
controller.table_items = [[NSMutableArray alloc] init];
controller.table_items = billtrackertablevalues;
} else {
NSLog(#"Error: %# %#", error, [error userInfo]);
}
}];
}
}
And here is my code for BillTrackerViewController:
#import "BillTrackerViewController.h"
#import "Parse/Parse.h"
#interface BillTrackerViewController ()
#end
#implementation BillTrackerViewController
#synthesize billView;
#synthesize refreshButton;
#synthesize table_items;
- (void)viewDidLoad
{
[super viewDidLoad];
[billView reloadData];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) { }
return self;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [table_items count];
}
- (UITableViewCell *)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"MainCell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"MainCell"];
}
NSString *cellText = table_items[indexPath.row];
cell.textLabel.text = cellText;
return cell;
}
#end
Once again, the table on BillTrackerViewController doesn't load values, but my initial array, billtrackertablevalues, is filled.
Thanks in advance, guys!
Change the following code:-
controller.table_items = [[NSMutableArray alloc] init];
controller.table_items = billtrackertablevalues;
as like following:-
controller.table_items = [[NSMutableArray alloc] initWithArray:billtrackertablevalues];
After that do NSLog at BillTrackerViewController in viewDidLoad method and let me know. Hope it will work.
I have a segue between MainViewController and BillTrackerViewController, both of which are UIViewController classes, but when i try to set a #property called event_name in BillTrackerViewController upon segue from MainViewController, the property remains null.
Because of this property, I am unable to use it to property query using Parse, as shown in the code below, and the app ends up crashing.
Code for MainViewController (segue name in question is "toBillTracker"):
#import "MenuViewController.h"
#import "AgendaViewController.h"
#import "BillTrackerViewController.h"
#import "ResearchViewController.h"
#import "Parse/Parse.h"
#interface MenuViewController ()
#end
#implementation MenuViewController {}
#synthesize event_name_label;
#synthesize event_name;
- (void)viewDidLoad
{
event_name_label.text = event_name;
[super viewDidLoad];
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:#"toBillTracker"]) {
BillTrackerViewController *controller=(BillTrackerViewController *)segue.destinationViewController;
controller.event_name = event_name;
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
#end
And here is the code for BillTrackerViewController.m:
#import "BillTrackerViewController.h"
#import "Parse/Parse.h"
#interface BillTrackerViewController ()
#end
#implementation BillTrackerViewController
#synthesize billView;
#synthesize refreshButton;
#synthesize event_name;
#synthesize event_id;
#synthesize resolution_names;
#synthesize resolution_pro_speakers;
#synthesize resolution_con_speakers;
#synthesize resolution_results;
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (IBAction)loadResolutions:(id)sender
{
resolution_names = [[NSMutableArray alloc] init];
resolution_pro_speakers = [[NSMutableArray alloc] init];
resolution_con_speakers = [[NSMutableArray alloc] init];
resolution_results = [[NSMutableArray alloc] init];
// Find event_id of the event
PFQuery *event_id_query = [PFQuery queryWithClassName:#"Event"];
[event_id_query whereKey:#"event_name" equalTo:event_name];
[event_id_query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
for (PFObject *object in objects) {
event_id = object.objectId;
}
} else {
NSLog(#"Error: %# %#", error, [error userInfo]);
}
}];
// Now, use that event_id to locate all of its resolutions
PFQuery *resolution_query = [PFQuery queryWithClassName:#"Resolution"];
[resolution_query whereKey:#"event_id" equalTo:event_id];
[resolution_query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
for (PFObject *object in objects) {
[resolution_names addObject:[object objectForKey:#"resolution_name"]];
// Sort resolutions in alphabetical order
resolution_names = (NSMutableArray*)[resolution_names sortedArrayUsingSelector:#selector(localizedCaseInsensitiveCompare:)];
}
// After sorting alphabetically, load other resolution data (pro speaker, result, etc.)
for (NSString *resolution_name in resolution_names) {
PFQuery *query = [PFQuery queryWithClassName:#"Resolution"];
[query whereKey:#"resolution_name" equalTo:resolution_name];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
for (PFObject *object in objects) {
[resolution_pro_speakers addObject:[object objectForKey:#"resolution_pro_speaker"]];
[resolution_con_speakers addObject:[object objectForKey:#"resolution_con_speaker"]];
switch ((int)[object objectForKey:#"resolution_result"]) {
case 0:
[resolution_results addObject:#"In Progress"];
case 1:
[resolution_results addObject:#"Passed"];
case 2:
[resolution_results addObject:#"Failed"];
case 3:
[resolution_results addObject:#"Passed with Amendment(s)"];
default:
[resolution_results addObject:#"In Progress"];
}
}
} else {
NSLog(#"Error: %# %#", error, [error userInfo]);
}
}];
}
} else {
NSLog(#"Error: %# %#", error, [error userInfo]);
}
}];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) { }
return self;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [resolution_names count];
}
- (UITableViewCell *)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"MainCell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"MainCell"];
}
NSString *cellText = [NSString stringWithFormat:#"%#\nPro: %#\nCon: %#\nResult: %#",resolution_names[indexPath.row], resolution_pro_speakers[indexPath.row], resolution_con_speakers[indexPath.row], resolution_results[indexPath.row]];
cell.textLabel.text = cellText;
return cell;
}
#end
Thanks so much!