Code:
NSString *full_string=@"The Quick Brown Fox Brown";
NSMutableArray *countloc=[[NSMutableArray alloc]init];
int temp=0;
int len=[full_string length];
for(int i =0;i<[full_string length];i++)
{
NSRange range=[full_string rangeOfString:@"Brown" options:0 range:NSMakeRange(temp,len-1)];
if(range.location<[full_string length])
[countloc addObject:[NSString stringWithFormat:@"%d",range.location]];
temp=range.location+1;
len=[full_string length]-range.location;
i=temp;
}
Here searching for the substring
Brown and
Location of the substring is stored in the array
countloc