Pregunta

I have an array called AllmyData[10][100000] and would like to concatenate the first 3 elements of each, ie Allmydata[1][i] & Allmydata[2][i] & Allmydata[3][i], into one string

I have tried using NSMutableString, as follows:

NSMutableString *xArray[]= [NSMutableString string];

//Create COMPARISSON string
for (i=0; i< 100000; i++) {
    [xArray[i] appendstring:AllmyData[1][i]];
    [xArray[i] appendstring:AllmyData[2][i]];
    [xArray[i] appendstring:AllmyData[3][i]];
    NSLog(xArray[i]);
}

However the above does not work..

thanks, Alex

¿Fue útil?

Solución

You're trying to use your mutable string like an array. Try the following:

NSMutableArray *array = [NSMutableArray new];

for (int i = 0; i < 100000; i++) 
{
    NSMutableString *myString = [NSMutableString new];
    [myString appendString:AllmyData[1][i]];
    [myString appendString:AllmyData[2][i]];
    [myString appendString:AllmyData[3][i]];

    [array addObject:myString];

    NSLog(myString);
}

However, that'll result in 100,000 log statements. Are you sure you want to do this?

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top