Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Can you try this one.</p> <pre><code>[detector enumerateMatchesInString:str options:0 range:NSMakeRange(0, [str length]) usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {                             NSDictionary *phoneNumber = [result addressComponents];                 NSLog(@"addressComponents  %@",phoneNumber);             }]; </code></pre> <p>If that does not work for you... The Address should be in a format that is </p> <pre><code>100 Main Street Anytown, NY 12345 USA </code></pre> <p>you can try other alternatives.. may be by converting your "str" into the above format...</p> <p>or directly you can try this..</p> <pre><code> NSArray *array = [tempAddrStr componentsSeparatedByString:@","]; if([array count]&gt;2) { NSString *str1 = [array objectAtIndex:[array count]-3]; NSString *str2 = [array objectAtIndex:[array count]-2]; str1=[str1 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; str1=[str1 stringByReplacingOccurrencesOfString:@"\n" withString:@" "]; str2=[str2 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; str2=[str2 stringByReplacingOccurrencesOfString:@"\n" withString:@" "]; tempAddrStr=[NSString stringWithFormat:@"%@, %@",str1,str2]; } else if([tempAddrStr length]&gt;=140&amp;&amp;[array count]&gt;1) { NSString *str1 = [array objectAtIndex:[array count]-2]; NSString *str2 = [array objectAtIndex:[array count]-1]; str1=[str1 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; str1=[str1 stringByReplacingOccurrencesOfString:@"\n" withString:@" "]; str2=[str2 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; str2=[str2 stringByReplacingOccurrencesOfString:@"\n" withString:@" "]; tempAddrStr=[NSString stringWithFormat:@"%@, %@",str1,str2]; } </code></pre> <p>This is a part of code from my project to just get the state and city from an given address returned by CLGeocoder.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload