zoukankan      html  css  js  c++  java
  • 代码中回调的用法

     

    //声明回调
    typedef void(^discoverCreateBackBlock)(BOOL state);
    
    @interface DiscoverCreateViewController
    //定义回调
    @property (nonatomic , copy) discoverCreateBackBlock finishBlock;    //发布成功回调Block
    @property (nonatomic, copy) GetCameraImageBlock getCameraImageBlock;
    .....
    @end




    //返回回调
    @implementation DiscoverCreateViewController
    
    #pragma mark --
    #pragma mark -- HTTPRequestDelegate
    
    - (void)request:(AFHTTPRequestOperation *)myRequest finshAction:(NSDictionary *)dic withURLTag:(NSString *)url{
        
        int code = [[dic safeObjectForKey:@"status"] intValue];
        if (code == 200) {
            
            //评论请求成功
            if ([url isEqualToString: DISCOVER_ADD_FOUND] ) {
                ...
                
                    //[self stopLoadAnimation];
                CL_INFO(@"评论请求完成完毕");
                if (_arrayPic.count !=0 && self.needExtractPhotosForAnimation) {
                    if (self.finishBlock) {
                        self.finishBlock(YES);
                    }
                }
                else{
                    [self onClickBack];
                }
            }
           
        }
    }
    
    @end



    //使用回调
        DiscoverCreateViewController*recommed = [[DiscoverCreateViewController alloc]init];
        recommed.arrayPic = [[NSMutableArray alloc] initWithArray:nil];
        recommed.canChooseProduct = NO;
        recommed.selectedEntity = self.selectedEntity;
        recommed.isRepost = YES;
        
        [recommed setFinishBlock:^(BOOL state){
            CL_INFO(@"发布完成,刷新我的关注页面数据");
            
        }];
        
        [self.navigationController pushViewController:recommed animated:YES];







  • 相关阅读:
    在linux上使用Android systrace
    perf性能调优
    未初始化内存检测(MSan)
    数据竞争检查工具(TSan)
    应用层内存溢出/越界/重复释放等问题检查工具(ASan)
    gperf heap profiler
    cmake打印shell
    github clone加速
    获取一个进程的所有物理地址上的内存
    Jenkins <1>: System Management
  • 原文地址:https://www.cnblogs.com/allanliu/p/4788081.html
Copyright © 2011-2022 走看看