1.About 真机
1.1 Xcode真机沙盒下载错误:Failed to download application container An error occured while attempting to download
解决:
真机沙盒查看内容下载时出现
Failed to download application container
An error occured while attempting to download the container from application "app" on "“XXX”的 iPhone" to "/Users/duanjichao/Documents/xxxx.xcappdata"
删除掉App 然后重启手机设备 重新运行App后即可
2.方法小记
2.1 ios中设置N秒后执行一个函数
设置N秒后执行一个函数,最常用的是设置一个定时器。
5秒后执行pushSecondController这个函数
[self performSelector:@selector(pushSecondController) withObject:nil afterDelay:5.0f];
比如:在第一个视图出现后5秒就跳转到第二个视图,代码如下:
- (void) pushSecondController{ SecondViewController *secondController = [[SecondViewController alloc] initWithNibName:nil bundle:NULL]; [self.navigationController pushViewController:secondController animated:YES]; }
- (void) viewDidAppear:(BOOL)paramAnimated{ [super viewDidAppear:paramAnimated]; [self performSelector:@selector(pushSecondController) withObject:nil afterDelay:5.0f]; }
5秒钟后又跳回第一个页面
- (void) goBack{ [self.navigationController popViewControllerAnimated:YES]; }
- (void) viewDidAppear:(BOOL)paramAnimated{ [super viewDidAppear:paramAnimated]; [self performSelector:@selector(goBack) withObject:nil afterDelay:5.0f]; }
2.2.1 连接字符串
NSArray *names = @["Hildr", @"Heidrun", @"Gerd", @"Guðrún", @"Freya", @"Nanna", @"Siv", @"Skaði", @"Gróa"];
NSString *result = [names componentsJoinedByString:@", "];
NSLog(@"%@",result);
打印结果:Hildr, Heidrun, Gerd, Guðrún, Freya, Nanna, Siv, Skaði, Gróa
2.2.2 “%”显示
如果想在NSString中显示双引号,一般是用转义字符,如 " ;
如果想在NSString中显示%就需要用%%,如:
NSString *strTest = [NSString stringWithFormat:@"%f%%",0.25];
NSlog("%@",strTest);
最后在控制台就会显示: 0.25%
Xcode 报错
“...xxx.app:resource fork, Finder information, or similar detritus not allowed”莫名其妙的错误!
1,关闭Xcode;
2,打开终端进入到‘DerivedData’目录:
cd ~/Library/Developer/Xcode/DerivedData/
3,在终端输入命令:
xattr -rc .