I’m translating a C code to understand objective-C differences from C.
I want to translate this instruction.
new_fitness += abs(int(population[i].str[j] - target[j]));
new_fitnees is an integer var. Target is an string and population is a which contains an string atribute called str.
I tried with this secuence:
new_fitness += abs( [[population objectAtIndex:i] cadena characterAtIndex:j] - [target characterAtIndex:j] );
I obtain an error message that tells a : is missing in first characterAtIndex.
new_fitnees is an NSInteger var. Target is an NSString and population is an NSMutableArray which contains an string atribute called cadena.
Finally, It’s better in Objetive-C split the C operation into 3 or 4 small operations? I think the sequence I did obtain i Obj-C is too complex to read.
wtf is “cadena” remove it. Also you will need intValue for objects
just tested – see no error