I have the following code:
int start = [html rangeOfString:@\"class=WordSection1>\"].location + 24;
int end = [html rangeOfString:@\"
Well.. you can't release mainHtml because it is created as an autorelease object, so release will get called after your function is done and it will crash if the object is already released by then.
You could try to create an extra function that splits the string and returns the array, perhaps with an own autorelease pool that you release after the function is run to make sure the strings are released.