在此之前,我在C中工作。现在我需要用swift语言编写我的项目。同时使利用AFNetworking类Web服务调用我创建了一个名为FSAPI类中,我创建了以下2个街区类型'AnyObject'的值没有成员'loginUserWithUsername'
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;
}
请有人帮助我。提前致谢。
请说明如何使用'sharedClient()'的定义。目前它的类型为AnyObject,这不是你想要的。 – Moritz
已添加sharedClient()定义。 – Arti