0

I use [webView shouldStartLoadWithRequest: navigationType:] to control the user navigation in a UIWebView. I was comparing the string with "isEqualToString" method like:

NSString *requestString = [[request URL] absoluteString];
if ([requestString isEqualToString:@"http://www.myComapnyWeb.com"])  return YES;
else return NO;

When the device was in IOS 4.3 this was working fine. Once the device got upgraded to IOS 5, (5.1.1 exactly), the above logic failed. With some NSLog, I noticed that the URL is returned all in lower case, (mycompanyweb instead of myCompanyWeb) and hence the above string comparison fails.

I can fix it by changing the comparison with lowercaseString method. Want to find out if anyone else experienced this. Any other solution? And in future, do we need to expect such changes?

4

1 回答 1

2

尝试:

NSString *requestString = [request.URL absoluteString];

那应该给你正确的情况。

我在 Xcode 4.5 版中测试过

至于“期待这样的变化”,他们总是有可能做出改变。有时是为了更好,有时....... =)

于 2012-10-11T21:12:03.350 回答