gpt4 book ai didi

ios - 类型 'AnyObject' 的值没有成员 'loginUserWithUsername'

转载 作者:行者123 更新时间:2023-11-30 13:56:52 25 4
gpt4 key购买 nike

在此之前,我使用 Objective C 工作。现在我需要用 swift 语言编写我的项目。在使用 AFNetworking 类进行 Web 服务调用时,我创建了一个名为 FSAPI 的类,在其中创建以下 2 个 block

typedef void (^requestCompletionBlock) (AFHTTPRequestOperation *operation, id responseObject);
typedef void (^requestFailureBlock) (AFHTTPRequestOperation *operation, NSError *error);

以及以下登录方法

//****************** Login Service **********************//
- (void)loginUserWithUsername:(NSString *)username
andPassword:(NSString *)password
andGrant_type:(NSString *)grantType
withCompletionBlock:(requestCompletionBlock)completionBlock
andFailureBlock:(requestFailureBlock)failureBlock;

现在我不知道如何快速调用这个电话。我已经创建了桥接头文件并将 FSAPI.h 导入其中。

    FSAPI.sharedClient().loginUserWithUsername("", andPassword: "", andGrant_type: "", withCompletionBlock: requestCompletionBlock() {
AFHTTPRequestOperation, id in

//to do

}, andFailureBlock: requestFailureBlock () {

})

+ (id)sharedClient {
static FSAPI *sharedClient = nil;
static dispatch_once_t oncePredicate;
dispatch_once(&oncePredicate, ^{
sharedClient = [[self alloc] initWithBaseURL:[NSURL URLWithString:baseServerURL]];
});
return sharedClient;
}

请有人帮助我。提前致谢。

最佳答案

尝试这个,因为 swift 中的 block 被视为闭包,

FSAPI.sharedClient().loginUserWithUsername("", andPassword: "", andGrant_type: "", withCompletionBlock: { (operation, response) -> Void in {

//to do in success case

}, andFailureBlock: { (operation, error) -> Void in {

//to do in error case

})

关于ios - 类型 'AnyObject' 的值没有成员 'loginUserWithUsername',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33520979/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com