2011-09-22 3 views
0

일부 데이터가로드되는 동안 "Please Wait"텍스트가있는 UIAlertView이 표시되어 사용자가 현재 처리중인 사항을 알 수 있습니다.NSOperationQueue Implemetation

그래서 나는의 UIAlertView 숨기기 - (있는 UITableViewCell *)있는 tableView : (jQuery과 *)있는 tableView cellForRowAtIndexPath을 : 그래서 지금 내가 NSOperationQueue을 처리하고있다 알아야 할

아래로 (NSIndexPath *) indexPath 기능 올바른 방식으로? 또는 아무것도 사용하지 못했습니다. NSOperationQueue

여기 내 코드입니다. 당신의 생각을 저에게 말 해주세요.

감사

-(void)buttonPressed 
{ 
alertLoading =[[UIAlertView alloc] initWithTitle:@"Loading Data" message:@"Please wait..." delegate:self cancelButtonTitle:nil otherButtonTitles:nil]; 
     av=[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; 
     [av startAnimating]; 
     [av setFrame:CGRectMake(125, 70, 37, 37)]; 
     //[self.view addSubview:alertLoading]; 
     [alertLoading show]; 
     [alertLoading addSubview:av]; 
     [av release]; 

     NSOperationQueue *queue = [NSOperationQueue new]; 
     NSInvocationOperation *operation = [[NSInvocationOperation alloc] 
              initWithTarget:self 
              selector:@selector(parsing) 
              object:nil]; 
     [queue addOperation:operation]; 
     [operation release]; 
     [queue release]; 
} 

-(void)parsing 
{ 
    NSString *searchUrl = [NSString stringWithFormat:@"%@profile.php?type=list&logged_id=%@&start=%d& rows=%d",ConstantURL,Reg_UserId_Trim,row_index,per_page]; 


    NSURL *xmlURL = [NSURL URLWithString:searchUrl]; 

    NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL]; 

    parserXML =[[XMLParser alloc]initXMLParser]; 

    profileName = [[ProfileName alloc]init]; 

    myProfileParser =[[MyProfileParser alloc]initMyProfileParser]; 

    //set the Delegate 
    [xmlParser setDelegate:parserXML]; 

    BOOL success = [xmlParser parse]; 

    if (success) 
    { 
     NSLog(@"Successfully Executed"); 
     [myTableView reloadData]; 
    } 
    else 
    { 
     NSLog(@"Error is occured"); 
    } 

    [av stopAnimating]; 

    [self performSelectorOnMainThread:@selector(loadPageDetails) withObject:nil waitUntilDone:NO]; 

    [myTableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:YES]; 
} 




// Customize the appearance of table view cells. 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if (cell == nil) 
    { 

    } 

    [alertLoading dismissWithClickedButtonIndex:0 animated:YES]; 

    return cell; 
} 

답변

1

당신은 NSOpeationQueue에 좋은 this 예를 볼 수 있습니다.
또한 this입니다.

0

NSOperationQueue을 만든 직후에 릴리스하지 말고 클래스에 대한 참조를 저장하고 클래스가 할당 해제 될 때 해제하십시오. 그렇지 않으면 작업이 실행되지 않을 수 있습니다.

관련 문제