read


<div style="font-family: Menlo; font-size: 11px; margin: 0px;">You can replace the string that you need to search with any string and it will return the number of replaces (the number of ocurrences of the string):

</div><pre style="background-image: URL(http://2.bp.blogspot.com/_z5ltvMQPaa8/SjJXr_U2YBI/AAAAAAAAAAM/46OqEP32CJ8/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"> int count = [baseString replaceOccurrencesOfString:@"stringToFind" withString:@"anyString" options:NSLiteralSearch range:NSMakeRange(0, [baseString length])];
</pre>
NOTE: Be careful, this will change the string in the baseString, so copy the string if you need to use it later.

Blog Logo

Daniel Gomez Rico


Published

Image

MakinGIANTS

The findings and tips records of an Android-iOS-TheWholeShabang group

Back to Overview