dimanche 22 novembre 2015

IOS how to check whether the i finish looping?

I have a for loop which is looping properly. But i want to check if the loop has finish looping, if yes i want to perform an action if no i want perform another action. please help me.

here is the codes:

- (void)viewDidLoad {
    [super viewDidLoad];

    [loadingview setHidden:NO];



    NSLog(@"Response recieved");

    output= [[NSMutableArray alloc] init];
    feeds = [[NSMutableArray alloc] init];
    deepsightSig = [[NSArray alloc] init];


    lastEl = [item_pass lastObject];


    for(int i = 0; i < item_pass.count; i++){

    NSString *soapMessage = //soap message


    url = [NSURL URLWithString:@"https://abc/SWS/hellworld.asmx"];

    theRequest = [NSMutableURLRequest requestWithURL:url];
    msgLength = [NSString stringWithFormat:@"%lu", (unsigned long)[soapMessage length]];


    [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
    [theRequest addValue: @"http://ift.tt/1Onpzn2" forHTTPHeaderField:@"SOAPAction"];
    [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
    [theRequest setHTTPMethod:@"POST"];
    [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];










    connection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
    [connection start];


        if(i == lastEl){


                badIPstring= [NSString stringWithFormat:@"%d", badIPCount];
                goodIPstring= [NSString stringWithFormat:@"%d", goodIPCount];
                items = @[[PNPieChartDataItem dataItemWithValue: [badIPstring intValue] color:PNLightBlue description:@"MSS Detection"],
                          [PNPieChartDataItem dataItemWithValue: [goodIPstring intValue] color:PNRed description:@"Vendor Alerts"]];
                self.pieChart = [[PNPieChart alloc] initWithFrame:CGRectMake((SCREEN_WIDTH - 230.0) /2.0, 230, 230.0, 230.0) items:items]; // this line move the position of piechart
                self.pieChart.descriptionTextColor = [UIColor whiteColor];
                self.pieChart.descriptionTextFont  = [UIFont fontWithName:@"Optima-Bold" size:13.0];
                self.pieChart.descriptionTextShadowColor = [UIColor whiteColor];
                self.pieChart.showAbsoluteValues = NO;
                self.pieChart.showOnlyValues = YES;
                [self.pieChart strokeChart];

                self.pieChart.legendStyle = PNLegendItemStyleStacked;
                self.pieChart.legendFont = [UIFont boldSystemFontOfSize:14.0f];

                UIView *legend = [self.pieChart getLegendWithMaxWidth:200];
                [legend setFrame:CGRectMake(30, 520, legend.frame.size.width, legend.frame.size.height)]; //this line move the position of the parameters below piechart

                [self.view addSubview:legend];
                [self.view addSubview:self.pieChart];
               [loadingview setHidden:YES];


        }
    }
}

Aucun commentaire:

Enregistrer un commentaire