块类型conflit

时间:2016-01-14 09:15:01

标签: ios block objective-c-blocks

- while I was using a block, it aways prompt block type confit,

结果如下:

 Redefinition of 'responseObject' with a different type: 'sucessBlock
 (__strong' (aka 'void (^__strong)(__strong id)') vs 'id _Nullable
   __strong' // here is the block declare: #import <Foundation/Foundation.h> typedef void(^sucessBlock)(id
   respondseObject); typedef void(^failureBlock)(NSError * error);


 #import <Foundation/Foundation.h>
    typedef void(^sucessBlock)(id respondseObject);
    typedef void(^failureBlock)(NSError * error);
    @interface TRAFNetWorkManager : NSObject
    +(void)sendGetRequestWithUrl:(NSString*)urlStr paramenters:(NSDictionary*)paramDic sucess:(sucessBlock)suscess failure:(failureBlock)failure;
    @end

//这里是补充#import

  #import "TRAFNetWorkManager.h"
    #import "AFNetworking.h"
    @implementation TRAFNetWorkManager

    +(void)sendGetRequestWithUrl:(NSString *)urlStr paramenters:(NSDictionary *)paramDic sucess:(sucessBlock)suscess failure:(failureBlock)failure {
        AFHTTPSessionManager* manager=[AFHTTPSessionManager manager];
        [manager GET:urlStr parameters:paramDic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {

            sucessBlock(responseObject);
        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

            NSError*error1=nil;
            failureBlock(error1);
        }];
    }

@end

1 个答案:

答案 0 :(得分:2)

SimpleDraweeViewsuccessBlock是块类型的名称。您不能将它们用于调用。相反,您需要使用块变量的名称,在您的情况下为failureBlocksuccess

failure