繁体   English   中英

将设备升级到iOS 8.3后,我的应用程序冻结

[英]My app freeze after upgrading my device to iOS 8.3

我最近将设备从8.1升级到了iOS 8.3。 在将应用程序设置为版本8.1时,我的应用程序在该设备上可以正常运行,但现在在升级之后,它就冻结了。

我调试并找出冻结的时间和原因。 我有5个容量为50的数组,每个数组包含从不同位置(ble,gps,视频)接收的字符串。 NSArray达到其容量时,我将所有内容都写到一个文件中,并从NSArray删除所有对象。 我有一个UIButton ,当按下它时,我便开始将数据收集到NSArray并将其写入文件->那就是它冻结了!

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:fileName];

//check if file exisits, if not creates one.
if(![[NSFileManager defaultManager]fileExistsAtPath:filePath])
{

    [[NSFileManager defaultManager] createFileAtPath:filePath contents:nil attributes:nil];
}
//writes and adds data the content to the specifec file.
NSFileHandle *fileHandler = [NSFileHandle fileHandleForUpdatingAtPath:filePath];
[fileHandler seekToEndOfFile];
[fileHandler writeData:[content dataUsingEncoding:NSUTF8StringEncoding]];
[fileHandler closeFile];

为什么设备的升级版本会对我的应用产生影响?

编辑:尽管设备被冻结,但控制台日志似乎仍在运行(我让他使用当前功能打印)。

正如Ashwin建议的那样,我将我的活动移至了后台线程,并且效果很好!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM