URL host comparison

Discussion in 'Mac Programming' started by saleh.hi.62, Nov 22, 2011.

  1. saleh.hi.62 macrumors member

    Joined:
    Jul 25, 2011
    #1
    Hello guys,

    here i am trying to compare the hosts of 2 URLs, eventhought that hosts are the same it does not respond why? !


    Code:
    	NSURL *url=[NSURL URLWithString:@"http://www.facebook.com/"?ref=logo" ];
    	NSURL *domain=[ NSURL URLWithString:@"http://www.facebook.com" ];
    	
    	if ( [url host]==[domain host] ) {
    	
    		NSLog(@"hosts are matched");
    	}else {
    		NSLog(@"hosts are not matched!");
    	}
    
     
  2. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #2
    What exactly does the "==" operator compare?

    Your code will only match the hosts if by coincidence both are exactly the same object. Not objects that are equal, but the same. You have to actually compare them. Then you need to read up on when url hosts should be considered equal. For example, is Facebook.com the same as facebook.com?
     
  3. jared_kipe macrumors 68030

    jared_kipe

    Joined:
    Dec 8, 2003
    Location:
    Seattle
    #3
    You're effectively using MR to crowd source whatever download agent you're building.

    Look at the documentation for NSString, there are a lot of different methods to do what you are looking for.
     

Share This Page