我正在开发一个应用程序。我从数组中获取字符串并从该字符串中替换 .xml 并转到下一页。如果我回来执行该代码,应用程序将在该替换字符串行崩溃。下面是我的代码.
-(void)open:(UITapGestureRecognizer*)recognizer
{
NSInteger i=(recognizer).view.tag;
NSMutableString *s1=[listoflessons objectAtIndex:i];
[default1 setObject:s1 forKey:@"KeyToXmlFile"];
NSLog(@"%@",[default1 objectForKey:@"KeyToXmlFile"]);
[s1 replaceCharactersInRange:[s1 rangeOfString: @".xml"] withString: @""];
[default1 setObject:s1 forKey:@"KeyToSelectedFile"];
[listoflessons removeObjectAtIndex:i];
[listoflessons insertObject:[default1 objectForKey:@"KeyToXmlFile"] atIndex:i];
NSLog(@"%@",listoflessons);
SecondViewCOntroller *snd=[[SecondViewCOntroller alloc]initWithNibName:@"SecondViewCOntroller" bundle:nil];
[self.navigationController pushViewController:snd animated:YES];
}
所以请告诉我如何避免那个。