Hi, I'm sure this is memory related but I can't seem to figure out what variable is causing me problems.
I'm releasing everything I allocate as far as I can tell. This loop seems to work fine if it runs 365 times but not 730 (its doing days in a year).
Here is the snippet of code that is failing.. it never gets out of the loop when the program ends on the device.
Any help is greatly appreciate. Thanks!
NSMutableArray *dtArray = [[NSMutableArray alloc] init];
double frequencyInterval = [Frequency doubleValue];
int i;
NSString *newDateString = @"";
NSString *sqlString = [NSString stringWithFormat:@"insert into ToDoList (TaskId, DueDate, Completed, Notes, Status, CompletedDate, Frequency) values ('%i', \"%@\", '0',\"%@\",'' ,'0', %@);", (int)self.AddTaskId, origDueDateString, NotesField, todoFrequency];
NSDate *nDate = dueDate;
NSDateFormatter *f3 = [[NSDateFormatter alloc] init];
[f3 setDateFormat:@"yyyy-MM-dd"];
for(i=0; i< 1000; i++) {
newDate = [newDate addTimeInterval:(frequencyInterval*86400)];
newDateString = [f3 stringFromDate:newDate];
if ([endRecurDate compare:newDate] == NSOrderedDescending)
{
[dtArray addObject:newDate];
if (i == 0)
{
sql = [sqlString stringByAppendingString:[NSString stringWithFormat:@"insert into ToDoList (TaskId, DueDate, Completed, Notes, Status, CompletedDate, Frequency) values ('%i', \"%@\", '0',\"%@\",'' ,'0', %@)", (int)self.AddTaskId, newDateString, NotesField, todoFrequency]];
}
else
{
sql = [sql stringByAppendingString:[NSString stringWithFormat:@";insert into ToDoList (TaskId, DueDate, Completed, Notes, Status, CompletedDate, Frequency) values ('%i', \"%@\", '0',\"%@\",'' ,'0', %@)", (int)self.AddTaskId, newDateString, NotesField, todoFrequency]];
}
//stringByAppendingString
}
else
{
break;
}
}
[dtArray release];
[f3 release];