的阵列我有一个数组类似下面找出剩余天数从日期
_combinedBirthdates(
"03/12/2013",
"03/12/2013",
"08/13/1990",
"12/09/1989",
"02/06",
"09/08",
"03/02/1990",
"08/22/1989",
"03/02",
"05/13",
"10/16",
"07/08",
"08/31/1990",
"04/14/1992",
"12/15/1905",
"08/14/1989",
"10/07/1987",
"07/25",
"07/17/1989",
"03/24/1987",
"07/28/1988",
"01/21/1990",
"10/13"
)
这一切都是NSString的
我想从这个,这使得新的数组包含天剩下下面的东西
(特定出生日期剩余的天数) (我们将比较当前日期与上面的日期数组,我们将f IND出剩余天数) _newarray( “125”, “100”, “65”,和 直到结束这样的.. )
我使用下面码本
unsigned int unitFlags = NSDayCalendarUnit;
NSCalendar *currCalendar = [[NSCalendar alloc]
initWithCalendarIdentifier:NSGregorianCalendar];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
NSLog(@" currCalendar%@",currCalendar);
NSMutableArray * _newarray = [[NSMutableArray alloc] init];
for (NSString * str in _combinedBirthdates){
NSDate * toDate = [dateFormatter dateFromString:str];
NSDateComponents *daysInfo = [currCalendar components:unitFlags fromDate:[NSDate date] toDate:toDate options:0];
int days = [daysInfo day];
[_newarray addObject:[NSString stringWithFormat:@"%d",days]];
}
NSLog(@" _newarray%@",_newarray);
这就是我得到的输出当我打印_newarray plz帮助我感谢你
_newlymadeArray(
"-1",
"-1",
"-8248",
"-8495",
"-4454",
"-4454",
"-8412",
"-8604",
"-4454",
"-4454",
"-4454",
"-4454",
"-8230",
"-7638",
"-39170",
"-8612",
"-9289",
"-4454",
"-8640",
"-9486",
"-8994",
"-8452",
"-4454",
"-2072",
"-888",
"-8315"
)
我不能让重量ü真正想要的: ( – iPatel 2013-03-13 05:08:40
天重新为特定的出生日期 – 2013-03-13 05:10:39
我认为这是解决在这个问题'http:// stackoverflow.com/questions/15358210/how-to-make-another-array-containing-number-of-days-remain' – 2013-03-13 05:11:55