Updating a UIProgressView while searching with Odata...

Nov 14, 2011 at 7:02 PM

This is probably more of an Objective C question than an Odata question, but my Search with Odata is taking a little long(5-10 seconds).  I would like to display a UIProgressView and just artificially set values every 2 or 3 seconds, but  I'm not sure how to get that done in Objective C.  Can anybody help me out with this? 

 

Thanks


Mark

 

Here is my search code...

-(IBAction)searchButtonClicked

{

 

    //---------------------------------

    //Create a proxy to the service...

    //---------------------------------

    CAEntities *proxy;

    @try {

        proxy = [[CAEntities alloc] initWithUri:@"http://SERVERNAME/ServiceName.svc/" credential:nil];

 

        NSString *searchName = talentTitleTextField.text;

        NSString *searchAgent = talentAgentTextField.text;

        NSString *searchAgency = talentAgencyTextField.text;

 

        DataServiceQuery *qry = [proxy talents];

 

        NSMutableString* filterString = [NSMutableString stringWithString: @"substringof('"];

 

        if([searchName length] > 0)

        {

            [filterString appendString: searchName];

            [filterString appendString:@"',name)"];

 

        }

 

        if([searchAgent length] > 0)

        {

            if([searchName length] > 0)

            {

                [filterString appendString:@" and substringof('"];

            }

            [filterString appendString: searchAgent];

            [filterString appendString:@"',Agent/name)"];

 

        }

 

        if([searchAgency length] > 0)

        {

            if([searchName length] > 0 || [searchAgent length] > 0)

            {

                [filterString appendString:@" and substringof('"];

            }

            [filterString appendString: searchAgency];

            [filterString appendString:@"',Agency/name)"];

        }

 

        [qry filter:filterString];

        [qry orderBy:@"name"];

 

        [qry expand:@"Credits/Show,Credits/Craft,Credits/Show/Genre,Credits/Show/Studio,Strengths/Genre,Agency,Agent"];

 

        QueryOperationResponse *result = [qry execute];

 

     //WOULD LIKE TO UPDATE PROGRESS VIEW EVERY 2 or 3 seconds while waiting for response to come back...

        while(something goes on...)

UIProgressView setProgress: xx value

 

         talentSearchResults = [[result getResult] retain];

 

        if([talentSearchResults count] > 0)

        {

            //Have to refresh the Data in the Table...

            [[self talentSearchResultsTable] reloadData];

        }

        else

        {

            //Show Simple Alert to let Viewer know they need to search again...

            UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Message Center"

                                                                message:@"0 Search Results.  Please refine your search" delegate:self 

                                                      cancelButtonTitle:@"OK" otherButtonTitles:nil];

            [alertView show];

            [alertView release];

        }

    }

    @catch(DataServiceRequestException *exception)

    {

        NSString *errMessage = [exception reason];

        //NSLog(errMessage);

        UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Message Center"

                                                            message:errMessage

                                                            delegate:self 

                                                  cancelButtonTitle:@"OK" otherButtonTitles:nil];

        [alertView show];

        [alertView release];

    }

   @finally {

        //cleanup

        [proxy release];

    }

 

 

 

}