Ios7 在视图之间传递NSString将返回NULL
我试图在视图之间返回一个Ios7 在视图之间传递NSString将返回NULL,ios7,nsstring,Ios7,Nsstring,我试图在视图之间返回一个NSString。代码如下: 数据源: .h: .m: 加载视图: .m: 我的问题是什么?看起来像是-(NSDate*)date从未调用过,并且selectedDate没有填入正确的值。 Please do this VIEWNAME *firstviewObj=[[VIEWName alloc]init]; NSDate *myDate = [firstviewobj date]; NSLog(@"%@",firstviewObj.selectedDate); Re
NSString
。代码如下:
数据源:
.h:
.m:
加载视图:
.m:
我的问题是什么?看起来像是-(NSDate*)date
从未调用过,并且selectedDate
没有填入正确的值。
Please do this
VIEWNAME *firstviewObj=[[VIEWName alloc]init];
NSDate *myDate = [firstviewobj date];
NSLog(@"%@",firstviewObj.selectedDate);
Remember myDate and firstviewObj.selectDate will give same result
@synthesise selectedDate;
-(NSDate *)date
{
NSInteger monthCount = [self.months count];
NSString *month = [self.months objectAtIndex:([self selectedRowInComponent:MONTH] % monthCount)];
NSInteger yearCount = [self.years count];
NSString *year = [self.years objectAtIndex:([self selectedRowInComponent:YEAR] % yearCount)];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"MMMM:yyyy"];
NSDate *date = [formatter dateFromString:[NSString stringWithFormat:@"%@:%@", month, year]];
selectedDate = [NSString stringWithFormat:@"%@", date];
return date;
}
[VIEWNAME] *firstviewObj=[[[VIEWNAME] alloc]init];
NSLog(@"%@",firstviewObj.selectedDate);
Please do this
VIEWNAME *firstviewObj=[[VIEWName alloc]init];
NSDate *myDate = [firstviewobj date];
NSLog(@"%@",firstviewObj.selectedDate);
Remember myDate and firstviewObj.selectDate will give same result