Hi everyone,
after some advice with a bit of code i have which seems to be going wrong somewhere but i cannot spot it.
heres the code and below is my guess at whats going wrong with it, can someone let me know where i am going wrong?
From what i can guess im using the object and assigning it to the array and even though i am (assuming i am) releasing it when it goes through the loop again and creates a new one, its being "reconnected" to the one in the array...
what am i doing wrong?
after some advice with a bit of code i have which seems to be going wrong somewhere but i cannot spot it.
heres the code and below is my guess at whats going wrong with it, can someone let me know where i am going wrong?
Code:
int n ;
NSMutableString *finalStringValue =[[NSMutableString alloc] init];
for (n = 1; n <= 10; n++)
{
TableData *dataObject = [[TableData alloc] init];
[finalStringValue setString:@"hello "];
[finalStringValue appendFormat:@"%d",n];
[dataObject setCity:finalStringValue];
[dataObject setNickname:@"Big Apple"];
[tableArray addObject: dataObject];
[dataObject release];
NSLog(finalStringValue);
}
[finalStringValue release];
From what i can guess im using the object and assigning it to the array and even though i am (assuming i am) releasing it when it goes through the loop again and creates a new one, its being "reconnected" to the one in the array...
what am i doing wrong?