I have an array of dates:
"2014-05-09 23:00:00 +0000",
"2014-05-09 23:00:00 +0000",
"2014-05-09 23:00:00 +0000",
"2014-05-09 23:00:00 +0000",
"2014-05-09 23:00:00 +0000",
"2014-05-09 23:00:00 +0000",
"2014-05-11 23:00:00 +0000",
"2014-05-11 23:00:00 +0000"
And i want to split this array to two different, and put in one array,
Result of what i want:
(
"2014-05-09 23:00:00 +0000",
"2014-05-09 23:00:00 +0000",
"2014-05-09 23:00:00 +0000",
"2014-05-09 23:00:00 +0000",
"2014-05-09 23:00:00 +0000",
"2014-05-09 23:00:00 +0000",
),
(
"2014-05-11 23:00:00 +0000",
"2014-05-11 23:00:00 +0000"
)
Here's what i've tried:
self.tempDatesArray - array of dates (unique)
tempArray - array of all dates
self.tempDatesArray = [[[NSOrderedSet orderedSetWithArray:[self.tempDatesArray copy]] array] mutableCopy]; // i'm getting all the unique dates from array
if (self.tempDatesArray.count > 0){
for (int j=0;j<self.tempDatesArray.count;j++){
if (tempArray[i] == self.tempDatesArray[j]){
[tempArray2 addObject:tempArray[i]]; // temp array
if (j++){
NSLog(@"i is %i",i);
[resultArray addObject:tempArray2];
NSLog(@"test %@",self.sectionsArray);
tempArray2 = [@[] mutableCopy];
}
}
}
}
And my result is :
(
"2014-05-09 23:00:00 +0000",
"2014-05-09 23:00:00 +0000",
"2014-05-09 23:00:00 +0000",
"2014-05-09 23:00:00 +0000",
"2014-05-09 23:00:00 +0000",
"2014-05-09 23:00:00 +0000",
"2014-05-11 23:00:00 +0000"
),
(
"2014-05-11 23:00:00 +0000"
)
I'm little frustrated because of this, can some one put me in right direction?