gpt4 book ai didi

objective-c - 找不到接受提供的参数的 'println' 的重载

转载 作者:搜寻专家 更新时间:2023-11-01 05:31:28 24 4
gpt4 key购买 nike

我在将我的 Objective-C 代码移植到 Swift 时遇到了一个奇怪的错误。我正在使用 https://github.com/AFNetworking/AFOAuth1Client 的桥接版本如果有帮助。

你能指出我哪里出了问题吗?谢谢。

一个有效的 Objective-C 代码:

[oauthClient authorizeUsingOAuthWithRequestTokenPath:@"oauth_request.php"
userAuthorizationPath:@"oauth_authorize.php"
callbackURL:[NSURL URLWithString:@"oob"]
accessTokenPath:@"oauth_access.php"
accessMethod:@"POST"
scope:nil
success:^(AFOAuth1Token *accessToken, id responseObject) {
NSLog(@"Success: %@", accessToken);
} failure:^(NSError *error) {
NSLog(@"Error: %@", error);
}];
}

Objective-C 中的引用方法原型(prototype):

- (void)authorizeUsingOAuthWithRequestTokenPath:(NSString *)requestTokenPath
userAuthorizationPath:(NSString *)userAuthorizationPath
callbackURL:(NSURL *)callbackURL
accessTokenPath:(NSString *)accessTokenPath
accessMethod:(NSString *)accessMethod
scope:(NSString *)scope
success:(void (^)(AFOAuth1Token *accessToken, id responseObject))success
failure:(void (^)(NSError *error))failure;

带有 Swift 代码的模板:

oauthClient.authorizeUsingOAuthWithRequestTokenPath(
requestTokenPath: String?,
userAuthorizationPath: <#String?#>,
callbackURL: <#NSURL?#>,
accessTokenPath: <#String?#>,
accessMethod: <#String?#>,
scope: <#String?#>,
success: ((AFOAuth1Token!, AnyObject!) -> Void)?,
failure: ((NSError!) -> Void)?
)

一个损坏的 Swift 代码:

oauthClient.authorizeUsingOAuthWithRequestTokenPath(
requestTokenPath: "oauth_request.php",
userAuthorizationPath: "oauth_authorize.php",
callbackURL: "oob",
accessTokenPath: "oauth_access.php",
accessMethod: "POST",
scope: nil,
success: { (accessToken: AFOAuth1Token!, responseObject: AnyObject!) in
println("Success")
},
failure: { (error: NSError!) in
println("Failure")
}
)

最佳答案

正如马特·吉布森建议的那样:

oauthClient.authorizeUsingOAuthWithRequestTokenPath(
"oauth_request.php",
userAuthorizationPath: "oauth_authorize.php",
callbackURL: NSURL(string: "oob"),
accessTokenPath: "oauth_access.php",
accessMethod: "POST",
scope: nil,
success: { (accessToken: AFOAuth1Token!, responseObject: AnyObject!) in
println("Success")
},
failure: { (error: NSError!) in
println("Failure")
}

)

工作起来很有魅力!非常感谢。

关于objective-c - 找不到接受提供的参数的 'println' 的重载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24223970/

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