Most memory efficient way to split an NSString in to substrings

前端 未结 2 1914
走了就别回头了
走了就别回头了 2021-01-15 03:29

I have the following code:

    int start = [html rangeOfString:@\"class=WordSection1>\"].location + 24;
    int end = [html rangeOfString:@\"
2条回答
  •  耶瑟儿~
    2021-01-15 04:01

    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.

提交回复
热议问题