ASIHTTPRequest帮助安装iPhone SDK


ASIHTTPRequest help with setup on iPhone SDK?

我在Xcode中创建了一个新项目,并执行以下操作来添加ASIHTTPRequest:

  • 将这些文件复制到主项目文件夹

    • ASIHTTPRequestConfig.h
    • ASIHTTPRequestDelegate.h
    • ASIProgressDelegate.h
    • ASICacheDelegate.h
    • ASIHTTPRequest.h
    • ASIHTTPRequest.m
    • ASIDataCompressor.h
    • ASIDataCompressor.m
    • ASIDataDecompressor.h
    • ASIDataDecompressor.m
    • ASIFormDataRequest.h
    • ASIInputStream.h
    • ASIInputStream.m
    • ASIFormDataRequest.m
    • ASINetworkQueue.h
    • ASINetworkQueue.m
    • ASIDownloadCache.h
    • ASIDownloadCache.m
    • ASIAuthenticationDialog.h
    • ASIAuthenticationDialog.m
    • Reachability.h(在External/Reachability文件夹中)
    • 可达性。m(在外部/可达性文件夹中)
  • 然后将这些文件拖到项目窗口的右侧

  • 然后我去,项目->编辑活动目标,点击+按钮,和[问题1]"CFNetwork.framework"不存在吗?

我现在想添加一个新的视图控制器,并使以下代码工作;

NSURL *url = [NSURL URLWithString:[[NSString stringWithFormat:@"http://www.mywebsite.com/script.php?first_name=%@",first_name] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request startSynchronous];
NSError *error = [request error];
NSString *response = nil;
if (!error) {
    response = [request responseString];
    NSLog(@"%@",response);
} else {
    return NO;
}
  • 我添加一个新的UIViewController子类文件
  • 我插入上面的代码和[问题2]它说'first_name'是未定义的和一堆其他错误。

我怎样才能解决这两个问题?我是否做错了什么,会阻碍我所期望的工作?(将变量发送到PHP文件,使用textfield和submit按钮)

谢谢!

我假设你使用的是Xcode4。

在项目导航器中单击"项目"。Project -> Select Target -> Select Build phases -> Expand Link Binary with Libraries -> Click +。您将找到框架。

您还没有声明变量first_name