Iphone 重定向url导致的问题

Iphone 重定向url导致的问题,iphone,objective-c,xcode,Iphone,Objective C,Xcode,在mac中通过浏览器在safari中打开将重定向到 我不知道为什么在我的代码中它从不重定向 将重定向到 我的URL有什么问题 NSURL *originalUrl=[NSURL URLWithString:@"http://ystatuschecker.com/n/iwall.php?tedad=1"]; NSData *data=nil; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:origi

在mac中通过浏览器在safari中打开将重定向到

我不知道为什么在我的代码中它从不重定向

将重定向到

我的URL有什么问题

    NSURL *originalUrl=[NSURL URLWithString:@"http://ystatuschecker.com/n/iwall.php?tedad=1"];
NSData *data=nil;  
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:originalUrl cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10];
NSURLResponse *response;
NSError *error;
data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSURL *LastURL=[response URL];
[request release];
[error release];

NSLog(@"%@",LastURL);

我认为您应该实现
连接:willSendRequest:redirectResponse:
委托方法

零或多个连接:willSendRequest:redirectResponse:如果确定下载必须重定向到新位置,则在发送任何其他消息之前,将向代理发送消息。委托可以允许重定向、修改目标或拒绝重定向

编辑

事实上,在查看之后,您提到的URL似乎没有使用普通的http代码进行重定向。我不确定他们是如何进行重定向的,但我认为这就是问题所在。

问题解决了。我曾经 标题(“位置:htpp://example.com")
在php文件中。

我不知道如何使用connection:willSendRequest:redirectResponse:plz给我一个示例代码……啊,我不知道你也能控制php。这将强制使用正确的重定向http状态来修复问题。