iphone - Handling try catch -
my project service oriented , comes services.i m loading data in uilabel's,tableviews etc.when particular text doesn't come service dont want show null there ,neither display view.so want redirect other view displays error image.but @try ,@catch not working.
-(void)viewdidload { //activity indicator code [self performselector:@selector(threadstartanimating) withobject:nil afterdelay:0.1]; nsstring *name=[nsstring stringwithformat:@"%@", self.provname]; cgsize constraint1 = cgsizemake(250, 2000.0f); cgsize size1 = [name sizewithfont: [uifont fontwithname:@"helvetica-bold" size:18] constrainedtosize:constraint1 linebreakmode:uilinebreakmodewordwrap]; self. pname =[[uilabel alloc] init]; @try { if([name length]>0 { self.pname.text=[nsstring stringwithformat:@"%@" ,name]; } else { nsexception *exception = [nsexception exceptionwithname:@"" reason:@"" userinfo:nil]; @throw exception; } } @catch (nsexception *exception) { errorview *errorview=[[errorview alloc]initwithnibname:@"errorview" bundle:nil]; if([[[uidevice currentdevice]systemversion]floatvalue]<5.0) { [self presentmodalviewcontroller:errorview animated:no]; } else { [self presentviewcontroller:errorview animated:no completion:nil]; } [errorview release]; } } - (void) threadstartanimating { //other code }
but when text length 0 not redirected errorview.instead rest of code in current view being executed.
i couldn't understand m going wrong?
Comments
Post a Comment