NSString *title = [myWebView
stringByEvaluatingJavaScriptFromString:@"document.title"];
NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:8];
int j = 0;
int i=0;
int count=0;
int len;
len = [title length];
for(i=0;i<len;i++){
NSString *c = [title substringWithRange:NSMakeRange(i, 1)];
if([c isEqualToString:@","])
{
//array[count]= [title substringWithRange:NSMakeRange(j, 2)];
NSString *xxx = [title substringWithRange:NSMakeRange(j,(i-j))];
NSLog(xxx);
//insert the string into array
[array insertObject:xxx atIndex:count];
j=i;
count = count + 1;
}
}
My app always crashes at the line
[c isEqualToString:@","]
and gives the error - Thread1 : Program received signal: "SIGBART".
I know for sure that the problem is occurring while comparing strings since the app runs if I remove that one line of code.
Can someone please help? Thanks
cvariable was somehow released. Is your sample code unedited ? Maybe you could try to enable zombie debugging for your application : cocoaforbreakfast.wordpress.com/2011/02/25/…NSRangeis invalid, you can get aNSRangeException. Are you sure there is none?