-(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];
}
所以请告诉我如何避免那个。
答案 0 :(得分:1)
我的猜测是“listoflessons”中的对象是NSString类型而不是NSMutableString。
尝试替换此行:
NSMutableString *s1=[listoflessons objectAtIndex:i];
用这个:
NSMutableString *s1=[[NSMutableString alloc] initWithString:[listoflessons objectAtIndex:i]];