Reputation: 484
I am using JSON parsing to upload data in UITableView
. Everything is working fine but after inserting data through textView it's uploading on server but it's not refreshing in my previous and current UITableView
. I need to restart my project to see the uploaded data. I want to reload my UITableView
after inserting data. I used [self.myTableView reloadData]
but it's not working anywhere.
-(PrayerListCustomCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
PrayerListCustomCell *cell = (PrayerListCustomCell *)[tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[NSBundle mainBundle]loadNibNamed:@"PrayerListCustomCell"
owner:self options:nil]objectAtIndex:0];
}
cell.dateLbl.text = [dateList objectAtIndex:indexPath.row];
cell.prayerLbl.text = [prayerList objectAtIndex:indexPath.row];
return cell;
}
-(void)submitClicked
{
if ([prayerTextView.text isEqualToString:@""]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Please fill
your request in text box!" delegate:self cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alert show];
}
else
{
prayerSubmitData = prayerTextView.text;
SubmitPrayer *submit = [[SubmitPrayer alloc]init];
[ASKevrOperationManager submitPrayer:submit handler:^(id object , NSError *error
, BOOL success)
{
if (success) {
NSLog(@"this is request data = %@",object);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
message:@"Successful upload!" delegate:nil cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
prayerTextView.text = @"";
[self.requestTableView reloadData];
//Do refreshment code
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
message:@"Please try again later!" delegate:nil cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
} ];
}
}
Upvotes: 0
Views: 538
Reputation: 3275
You need to add your committed data into your prayerList
array. This should be something like this:
if (success) {
// show alert
[prayerList addObject:prayerTextView.text];
[self.requestTableView reloadData];
prayerTextView.text = @"";
//Do refreshment code
}
Upvotes: 1