I'm new in programming, and still don't understand some things. Please help me with this. I have created two textField's and one button on my first ViewController. button calculate values from this two textField's. I want to store this result to tableView in second ViewController in my Storyboard. How can i send this values (NSString) to another .h file and create new cell in tableView with text (result from textField's)
this is my IBAction for button:
- (IBAction)pocitadloSpotreby:(UIButton*)pripocitaj{
double value1 = [litre.text doubleValue];
double value2 = [kilometre.text doubleValue];
double result = (value1 / value2) * 100;
self.display.text = [NSString stringWithFormat:@"%.2lf", result];
}
and this is my .m file where i have tableView (and of course UITableViewDelegate, UITableViewDataSource:
@interface FlipsideViewController ()
{
NSMutableArray *novyZaznam;
}
@end
@implementation FlipsideViewController
- (void)viewDidLoad
{
[super viewDidLoad];
novyZaznam = [[NSMutableArray alloc]init];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return novyZaznam.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSString *cellValue = [novyZaznam objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}
@end
I dont know how can i insert new row (cell) into my tableView with text from textField and result NSString.
Thank you for any help!