I'm trying to replace a string in an array(update array) with a string found at an index of array(other array). Both arrays are initialized in init and i can nslog them in this method. if [str isEqualToString:[otherArray objectAtIndex:i] i want to return true/YES
but the line: [updateArray replaceObjectAtIndex:i withObject:str]; is giving bad access to program. (its only a console program) "Program received signal: “EXC_BAD_ACCESS”.
any suggestions appreciated, thanks trev
-(BOOL)checker:(NSString *)str {
NSLog(@"update arrayobject at %d is %@",0, [updateArray objectAtIndex:0]);
NSLog(@"otherArray size is %d",[otherArray count]);
NSLog(@"str iput is %@",str);
int i;
for (i=0; i<[otherArray count]; i++) {
if ([str isEqualToString:[otherArray objectAtIndex:i]]) {
[updateArray replaceObjectAtIndex:i withObject:str];
return TRUE;
}
开发者_JS百科 }
return FALSE;
}
once check your array is it allocated or not properly..i think there is nothing more than that thing..
精彩评论