如何将Swift Bool值传递给Objective-C的方法?

时间:2016-12-28 08:48:58

标签: ios objective-c swift boolean

我有一个由Mysevers撰写的Objective-c网络类,现在我使用的是混合Objective-cSwift项目。

在我的Mysevers中,我有一种联网方法:

+(void)AFPOSTWithHud:(BOOL)hud andAddressname:(NSString*)addressName parmas:(NSDictionary*)parmas RequestSuccess:(void(^)(id result))success failBlcok:(void(^)(void))failBlcok
{
    if (hud) {
        [HUD addHUD];
    }
    AFHTTPSessionManager *requestManager = [AFHTTPSessionManager manager];

    NSString *urlStr = [NSString stringWithFormat:@"%@%@",BASE_URL,addressName];
    NSLog(@"%@",urlStr);


    [requestManager POST:urlStr parameters:parmas progress:^(NSProgress * _Nonnull uploadProgress) {

    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {

        if (hud) {
            [HUD removeHUD];
        }
        success(responseObject);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

    if (error != nil) {
        NSLog(@"error==%@",[error localizedDescription]);
        if (hud) {
            [HUD removeHUD];
            }

        }
        failBlcok();
    }];


}

Swift控制器中,调用方法,传递一个快速的Bool值false

 Mysevers.afpost(withHud: false, andAddressname: Global.url_fillMoreInfo, parmas: uploadDict, requestSuccess:{ (result) in

但是,在Mysevers类中,我给出一个断点来检查传递的值,结果是YES

(lldb) po hud
YES

0 个答案:

没有答案