Answer the question
In order to leave comments, you need to log in
Why is the data being reset in the array?
Hello everyone))
I have written a method:
-(NSArray*)creatingMultipleCards:(NSArray*)array{
NSMutableArray *tmpCards = [NSMutableArray new];
//Будем проверять каждую карточку на содержание нескольких дат. В случае если дат больше одной, то формируем несколько карточек.
for(Card *obj in array){
if ([obj.urgencyTimes count] > 1) {
//Если у карточки больше одной даты, то формируем для каждой даты отдельную карточку.
for (UrgencyTime *cardTime in obj.urgencyTimes) {
Card *tmp = obj;
tmp.beginDate = cardTime.start;
tmp.endDate = cardTime.end;
[tmpCards addObject:tmp];
}
}
else
{
[tmpCards addObject:obj];
}
}
return tmpCards;
}
Answer the question
In order to leave comments, you need to log in
You need to replace
Card *tmp = obj;
On
Card *tmp = [obj copy]
or
Card *tmp = [Card new];
Depending on the specifics of what you're doing,
I can't see all the properties of the Card
To what was said by the previous speaker, I will explain why you need to do what he advised.
Here is your code:
for (UrgencyTime *cardTime in obj.urgencyTimes) {
Card *tmp = obj;
tmp.beginDate = cardTime.start;
tmp.endDate = cardTime.end;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question