Note that there are some explanatory texts on larger screens.

plurals
  1. PONSRegularExpression:enumerateMatchesInString hangs when called more than once
    primarykey
    data
    text
    <p>In the context of an iPhone app I am developing, I am parsing some html to extract data to map, using NSRegularExpression. This information is updated whenever the user "pans" the map to a new location. </p> <p>This works fine the first time or two through, but on the second or third time the function is called, the application hangs. I have used XCode's profiler to confirm I am not leaking memory, and no error is generated (the application does not terminate, it just sits in execution at the point shown below).</p> <p>When I examine the HTML being parsed, I do not see that it is incomplete or otherwise garbled when the application hangs.</p> <p>Furthermore, if I replace the regex code with a collection of explicitly address strings, everything works as expected. </p> <pre><code>- (void)connectionDidFinishLoading:(NSURLConnection *)connection { // receivedData contains the returned HTML NSString *result = [[NSString alloc] initWithData:receivedData encoding:NSASCIIStringEncoding]; NSError *error = nil; NSString *pattern = @"description.*?h4&gt;(.*?)&lt;\\/h4&gt;.*?\"address&gt;[ \\s]*(.*?)&lt;.*?zip&gt;.*?(\\d{5,5}), US&lt;"; NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:NSRegularExpressionDotMatchesLineSeparators error:&amp;error]; __block NSUInteger counter = 0; // the application hangs on the next line after 1-2 times through [regex enumerateMatchesInString:result options:0 range:NSMakeRange(0, [result length]) usingBlock:^(NSTextCheckingResult *match, NSMatchingFlags flags, BOOL *stop){ NSRange range = [match rangeAtIndex:2]; NSString *streetAddress =[result substringWithRange:range]; range = [match rangeAtIndex:3]; NSString *cityStateZip = [result substringWithRange:range]; NSString *address = [NSString stringWithFormat:@"%@ %@", streetAddress, cityStateZip]; EKItemInfo *party = [self addItem:address]; // geocode address and then map it if (++counter &gt; 4) *stop = true; }]; [receivedData release]; [result release]; [connection release]; //alloc'd previously, so release here. } </code></pre> <p>I realize this is going to be difficult/impossible to duplicate, but I was wondering if anyone has run into a similar issue with NSRegularExpression or if there is something obviously wrong here.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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