views:

103

answers:

1

I am trying to compare the current url in webView with a defined url say google.com

so in theory..

 NSURLRequest *currentRequest = [webView request];
 NSURL *currentURL = [currentRequest URL];

would give us our current url...

  NSString *newurl = @"http://www.google.com";

this would give us the compared to defined url

 while (!currentURL == newurl) {
  //do whatever here because currentURL does not equal the newurl
 }

This does not seem to work though.. solutions?

+1  A: 

You have to use -isEqualToString:, like so:

while (![currentURL isEqualToString:newURL]) {
  // Do stuff
}

You can't use that to compare URLs to strings, tho', so you'll have to convert one or the other (converting newurl to an URL and comparing using -isEqual: might be a good move).

Williham Totland
I tried that and get the following warning: 'NSURL' may not respond to '-isEqualToString:'"-[NSURL isEqualToString:]: unrecognized selector sent to instance"Any ideas?
Syleron