I hope someone understands what happens to my NSMutableArray.
I read records a, b, c, d from a database, load the fields into an object an add the object to an array. To do this I read the records into an instance of that object (tmpEvent) and add the Object to the target array (NSMutableArray myArray).
the code looks like:
for (condition) {
tmpEvent.field1 = [NSString stringWithUTF8String:(char*)sqlite3_column_text(stmt, 0)];
tmpEvent.field2 = [NSString stringWithUTF8String:(char*)sqlite3_column_text(stmt, 1)];
tmpEvent.field3 = [NSString stringWithUTF8String:(char*)sqlite3_column_text(stmt, 2)];
NSLog(@"myArray: adding %@", tmpEvent.field1);
[myArray addObject:tmpEvent];
}
The NSLog shows
myArray: adding a
myArray: adding b
myArray: adding c
myArray: adding d
Subsequent I enumerate the array (this can be in the same or a different method):
for (myObject *records in myArray) {
NSLog(@"iEvents value %@", records.field1);
}
The NSLog now shows:
myArray value d
myArray value d
myArray value d
myArray value d
a mystery .... ??? any thoughts?