ios - “ASIHTTPRequest”未响应 setPostValue,需要将电子邮件 ID 作为参数传递

标签 ios asihttprequest

我是 iOS 开发的新手,最近我在使用“ASIHTTPRequest”库。我已经从 Here 下载了它的示例.它工作正常。我需要将参数作为“电子邮件”发送到我的 Web 服务,并且还需要身份验证。

我试着跟随 [request setPostValue:@"abcd@gmail.com"forKey:@"email"]; 基于 this Reference

但它警告我 Instance method -setPostValue:forKey() not found。如何将电子邮件 ID 作为参数传递给 Web 服务?供您引用,我使用网络服务在用户忘记密码时重置密码。

编辑:

现在,我需要使用电子邮件 ID 参数和身份验证将以下代码从 ASIHTTPRequest 转换为 ASIFormDataRequest。你现在能帮我吗? `

[self setRequest:[ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://abc.foo.com/api/forgot_password/"]]];
    [request setUseKeychainPersistence:[useKeychain isOn]];

[request setDelegate:self];
[request setShouldPresentAuthenticationDialog:[useBuiltInDialog isOn]];
[request setDidFinishSelector:@selector(topSecretFetchComplete:)];
[request setDidFailSelector:@selector(topSecretFetchFailed:)];
[request startAsynchronous];

`

最佳答案

那是因为ASIHTTPRequest不包括 -setPostValue:forKey: 方法。 ASIFormDataRequest ,另一方面,确实如此。

听起来您正在使用 ASIHTTPRequest* 类型的指针向 ASIFormDataRequest 的实例发送消息。如果指针确实指向表单数据请求,那没关系,ASIFormDataRequest 是 ASIHTTPRequest 的子类,但是如果您对对象的类型足够确定,可以向它发送特定于它的类型的消息,那么您也足够了解要么首先使用更具体的类型,要么使用类型转换让编译器知道它不需要提示。

关于ios - “ASIHTTPRequest”未响应 setPostValue,需要将电子邮件 ID 作为参数传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17725484/

相关文章:

iphone - AFNetworking 有后台支持吗?

ios - 如何使用 Iphone 应用程序的基本身份验证登录 Rails 服务器并保持登录状态?

ios - 未找到 UIApplicationLaunchOptionsKey

ios - 在 swift 中为登录 View Controller 的背景添加模糊效果

ios 自定义tableview的多选

ios - UIStackView:添加具有相同宽度的排列 View

ios - 使用 SpriteKit 和内置物理引擎移动和跳跃 Sprite

ios - 访问web时,block和不block有什么区别

iphone - ASIHttprequest 用于登录认证

iphone - ASIHTTPRequest : Adding Header which should send with every request