2

This Application sends data (through a dictionary) two following instances to other views from the sender.

  1. Home Page TableviewCell to each particular view according to each state Ex- IF state 1 - AppointmentView 2 - OnthewayView 3 - TimerView 4 - Invoice View.

    • Home ---> Appointment
    • Home ---> ontheWay
    • Home ---> TimerView
    • Home ---> Invoice
  2. Home ---> AppointmentView ---> ontheway --> timer ---> Invoice

I have an issue when I navigating timer --> Invoice the timer going as empty timer = "" so some of my functions (time fee calculation) are not working on this instance only.

But the same as 1st instance when I go back to Home and Home -> invoice timer=10 and rest of the functions works.

code snippet for 1st instance (the working one) (homeviewcontroller)


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.section==0) {
        if (bookingArray.count) {
            NSInteger keyStatus =[bookingArray[indexPath.row][@"status"] integerValue] ;
            switch (keyStatus) {
                case 2:
                    [self performSegueWithIdentifier:@"appointmentDetail" sender:bookingArray[indexPath.row]];
                    break;
                case 5:
                    [self performSegueWithIdentifier:@"ToMapController" sender:bookingArray[indexPath.row]];
                    break;
                case 6:
                    [self performSegueWithIdentifier:@"ToTimerVC" sender:bookingArray[indexPath.row]];
                    break;
                case 21:
                    [self performSegueWithIdentifier:@"ToTimerVC" sender:bookingArray[indexPath.row]];
                    break;
                case 22:
                    [self performSegueWithIdentifier:@"ToInvoice" sender:bookingArray[indexPath.row]];
                    break;
            }

Second instance (Not working) (timerViewController)

-(void)onTHEWAYButtonTapped
{

    self.navigationItem.leftBarButtonItem.enabled = NO;

    [[ProgressIndicator sharedInstance]showPIOnView:self.view withMessage:NSLocalizedString(@"Loading..",@"Loading..")];

    switch (_bookingStatu) {
        case 2:
        case 5:
        case 21:{
            _bookingStatu = 6;

            break;
        }
        case 6:{
            _bookingStatu = 22;
            break;
        }
        default:
            break;
    }
    NSDictionary *parameters;
    if (_bookingStatu==6) {
        parameters = @{
                       kSMPcheckUserSessionToken: [[NSUserDefaults standardUserDefaults] objectForKey:KDAcheckUserSessionToken],
                       kSMPCommonDevideId       :[[NSUserDefaults standardUserDefaults] objectForKey:kPMDDeviceIdKey],
                       @"ent_appnt_dt"          :self.dictBookingDetails[@"apntDt"],
                       KSMPPatientEmail         :self.dictBookingDetails[@"email"],
                       kSMPRespondResponse      :[NSString stringWithFormat:@"%ld",(long)_bookingStatu],
                       @"ent_date_time"         :[Helper getCurrentDateTime],
                       @"ent_bid"                :self.dictBookingDetails[@"bid"],
                       @"bookingId"              :_dictBookingDetails[@"bid"],
                       @"technicianId"           :[[NSUserDefaults standardUserDefaults] objectForKey:@"ProviderId"],
                       @"latitude"                :_dictBookingDetails[@"apptLat"],
                       @"longitude"               :_dictBookingDetails[@"apptLong"]
                       //temp test



                       };
        NSLog(@"Check the sent param-1%@",parameters);
    }else if (_bookingStatu==22)  {
        parameters = @{
                       kSMPcheckUserSessionToken: [[NSUserDefaults standardUserDefaults] objectForKey:KDAcheckUserSessionToken],
                       kSMPCommonDevideId       :[[NSUserDefaults standardUserDefaults] objectForKey:kPMDDeviceIdKey],
                       @"ent_appnt_dt"          :self.dictBookingDetails[@"apntDt"],
                       KSMPPatientEmail         :self.dictBookingDetails[@"email"],
                       kSMPRespondResponse      :[NSString stringWithFormat:@"%ld",(long)_bookingStatu],
                       @"ent_date_time"         :[Helper getCurrentDateTime],
                       @"ent_bid"                :self.dictBookingDetails[@"bid"],
                       @"ent_timer":[NSString stringWithFormat:@"%d",(timeHr*3600)+(timeMin*60)+timeSec],
                       @"bookingId"              :_dictBookingDetails[@"bid"],
                       @"technicianId"           :[[NSUserDefaults standardUserDefaults] objectForKey:@"ProviderId"],
                       @"latitude"                :_dictBookingDetails[@"apptLat"],
                       @"longitude"               :_dictBookingDetails[@"apptLong"],

                       };

        NSLog(@"Check the sent param-2%@",parameters);
    }

    NetworkHandler *handler = [NetworkHandler sharedInstance];

    [handler composeRequestWithMethod:MethodupdateApptStatus
                              paramas:parameters
                         onComplition:^(BOOL succeeded, NSDictionary *response) {
                             [[ProgressIndicator sharedInstance]hideProgressIndicator];
                             [_customSliderView sliderImageOrigin];
                             if (succeeded) {
                                 if ([response[@"errFlag"] isEqualToString:@"1"]) {
                                     [Helper showAlertWithTitle:NSLocalizedString(@"Message", @"Message") Message:response[@"errMsg"]];
                                     if([[response objectForKey:@"errNum"] intValue] == 41){
                                         [Helper showAlertWithTitle:NSLocalizedString(@"Error",@"Error") Message:[response objectForKey:@"errMsg"]];
                                         [self backButtonPressed];
                                     }else if ([[response objectForKey:@"errNum"] intValue] == 83){
                                         [self userSessionTokenExpire];
                                     }
                                 }else{

                                     [self emitTheBookingACk:_bookingStatu];
                                     [self updateCustomerinfo];
                                     if (_bookingStatu==22) {
                                         [self getTimerAPI];

                                         [self performSegueWithIdentifier:@"toInvoiceSegue" sender:_dictBookingDetails];
                                     }else if (_bookingStatu==6){
                                         [self pauseTimer:nil];
                                     }
                                 }
                             }
                             else
                             {
                                 NSLog(@"Error");
                                 [[ProgressIndicator sharedInstance] hideProgressIndicator];
                             }
                         }];

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{

     if([segue.identifier isEqualToString:@"toReportView"])
    {
        RecomReportViewController *reportView = (RecomReportViewController *)segue.destinationViewController;
        reportView.bookingId = bookingID;
        reportView.taskLocation = taskLocation;

    }
   else if([[segue identifier] isEqualToString:@"toInvoiceSegue"])
    {
        InvoiceViewController *details =[segue destinationViewController];

        details.minutesCount=[NSString stringWithFormat:@"%d",(timeHr*3600)+(timeMin*60)+timeSec];
        details.currentTimer = timerfinished;
        [self getTimerAPI];
        details.dictBookingDetails = sender;

    }

    return;

InvoiceViewController.m —

- (void)viewDidLoad {
    [super viewDidLoad];
    //sending request to get materialfee
    NSString *testTimer = _dictBookingDetails[@"timer"];
}

Please help me to find out the bug and fix the issue...

Fido
  • 218
  • 1
  • 17
  • What is sender in `details.dictBookingDetails = sender;` in `TimerViewController`? – Mahendra Feb 20 '18 at 07:25
  • @MahendraGP [self performSegueWithIdentifier:@"toInvoiceSegue" sender:_dictBookingDetails]; – Fido Feb 20 '18 at 07:32
  • In `TimerViewController` the dictionary `_dictBookingDetails` contains the "timer" key, please verify it. – Mahendra Feb 20 '18 at 07:33
  • @MahendraGP this data sending through a slider that slider has two booking status so the first status "bookingstatu==6" not required the timer key (because timer is runnig at that moment) and the "bookingstatu==22" only required timer key.. check the code. – Fido Feb 20 '18 at 07:36
  • in `_bookingStatu==22` where is "timer" key..!! – Mahendra Feb 20 '18 at 07:42
  • @MahendraGP this is the timer key for _bookingStatu == 22 @"ent_timer":[NSString stringWithFormat:@"%d",(timeHr*3600)+(timeMin*60)+timeSec], – Fido Feb 20 '18 at 07:43
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/165467/discussion-between-fido-and-mahendra-gp). – Fido Feb 20 '18 at 07:44

0 Answers0