title: Objective C - Extract substring by finding first and second occurrence of a character
body: <p>I am trying to port my Android app to iOS. I need to extract the string present between the first and second occurrence of the single quote <code>'</code> character.</p>
  
  <p>For example, from <code>javascript:popUpWindow7('news_details.asp?slno=2029',620,300,100,100,'yes')</code>, I need to extract <code>news_details.asp?slno=2029</code>.</p>
  
  <p>In Java, I did this:</p>
  
  <pre><code>String inputUrl = "javascript:popUpWindow7('news_details.asp?slno=2029',620,300,100,100,'yes')";
  StringBuilder url = new StringBuilder();
  url.append(inputUrl.substring(inputUrl.indexOf('\'')+1, 
                  inputUrl.indexOf('\'',inputUrl.indexOf('\'')+1)));
  </code></pre>
  
  <p>I can't find any method similar to indexOf in Objective C, so I did the following:</p>
  
  <pre><code>NSUInteger length =0;
  NSMutableString* url;
  
  NSString* urlToDecode = @"javascript:popUpWindow7('news_details.asp?slno=2029',620,300,100,100,'yes')";
  
  for (NSInteger i=[urlToDecode rangeOfString:@"\'"].location +1; i&lt;urlToDecode.length; i++) {
  
      if([urlToDecode characterAtIndex:i]== '\'')
      {
          length = i;
          break;
      }
  }
  
  NSRange range = NSMakeRange([urlToDecode rangeOfString:@"\'"].location +1, length);
  
  [url appendString:[urlToDecode substringWithRange:range]];
  </code></pre>
  
  <p>What am I doing wrong?</p>