0
votes

I have a date picker to calcuclate age. When first time I select date it shows correct o/p but when next time I select date - app crashes.

My code:

NSDate *selected = [date1 date];
NSDateFormatter *df=[[NSDateFormatter alloc] init];


float interval=[selected timeIntervalSinceNow] * -1.0;

float year=interval/31556926;

if (year>10)
{
    alert.tag=0;
    alert=[[UIAlertView alloc]initWithTitle:@"Calculate Age" message:@"Congratulation!!!!Your Age Is Grater Than 10"  delegate:self cancelButtonTitle:@"Cancel"  otherButtonTitles:@"Ok", nil];
    [alert show];
    [alert release];             
}

` log: Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted. 2012-07-02 13:38:19.568 loginDemo[1848:f803] Unbalanced calls to begin/end appearance transitions for . 2012-07-02 13:38:30.658 loginDemo[1848:f803] -[__NSCFType setTag:]: unrecognized selector sent to instance 0x68dd0d0 2012-07-02 13:38:30.660 loginDemo[1848:f803] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType setTag:]: unrecognized selector sent to instance 0x68dd0d0' * First throw call stack:

` I didn't use UIPickerDelegate because no method of delegate was required in this. In this when i click on 'OK' button of alert view then transition should be done.

1
where it get crashed? also write the log which you get on your console..Apurv

1 Answers

0
votes

Just put your alert.tag = 0 line below the alert = [[UIAlertView alloc].... line that will solved your problem.

Also change the tag value to other then 0 as all the view in xib has tag value 0 by default.