- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的应用程序中,我有一个预填充的 sqlite 数据库,它是使用我创建的另一个应用程序的核心数据创建的,因此数据模型是相同的。我把它复制过来,一切都很好。我在每个可以运行 iOS 6.0 的 iOS 设备上都尝试过它,因为这就是我正在构建的目标。即使在早期的 iPod Touch 上,该应用程序也能正常工作。数据库在旧设备上复制大约需要 45 秒。该应用程序运行所有数据,所有设备测试都很好,没有问题。我在应用程序商店发布了该应用程序,发现在旧设备上,该应用程序在首次加载时崩溃了。我假设这是一个内存相关的问题。我最困惑的是,与我联系的购买它的客户拥有同一部 iPhone 4S 手机,其中一位报告它工作正常,而另一位则说它崩溃了。我在想一个有早期的 4S,而另一个有一个较晚的 4S。我确认他们在手机上也有空间来复制数据。当我从 Xcode 运行应用程序时,无论使用何种设备,它都不会崩溃。
我的问题是有人知道为什么会发生这种情况以及可能的解决方法吗?
也许有一种更有效的方法,不会让应用程序在第一次加载时花费将近一分钟的时间?任何帮助都会很棒,因为我很茫然。我查看了大约 30 个其他问题,其中一些与此类似,但它们确实没有回答我需要的问题。
我也想对你们所有人说声谢谢,因为我住在这个网站上,并且从你们的所有问题和答案中学到了很多东西。
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if (_persistentStoreCoordinator != nil) {
return _persistentStoreCoordinator;
}
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"Data.sqlite"];
#define UPGRADE_COPY_STORE_FROM_BUNDLE
#ifdef UPGRADE_COPY_STORE_FROM_BUNDLE
if (![[NSFileManager defaultManager] fileExistsAtPath:[storeURL path]]) {
NSString *dataPath = [[NSBundle mainBundle]pathForResource:@"Data" ofType:@"sqlite" inDirectory:nil];
NSError *anyError = nil;
BOOL success = [[NSFileManager defaultManager] copyItemAtPath:dataPath toPath:[storeURL path] error:&anyError];
if (!success) NSLog(@"Error copying file: %@", anyError);
}
#endif
NSError *error = nil;
_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
}
return _persistentStoreCoordinator;
}
还附有来自设备的崩溃日志。已更新
Incident Identifier: CCFB748D-5A2A-45CE-B9EC-19811CCDC696
CrashReporter Key: 71b2c2b3b88abfe03baa87e7f588642dcec0ff08
Hardware Model: iPod4,1
Process: Upgrade [2513]
Path: /var/mobile/Applications/27C440D4-0210-48BB-A287-570FAEDE3369/Upgrade.app/Upgrade
Identifier: Upgrade
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2013-07-27 23:23:57.479 -0600
OS Version: iOS 6.1.2 (10B146)
Report Version: 104
Exception Type: 00000020
Exception Codes: 0x000000008badf00d
Highlighted Thread: 0
Application Specific Information:
com.JonPhillips.Upgrade failed to launch in time
Elapsed total CPU time (seconds): 2.450 (user 2.450, system 0.000), 12% CPU
Elapsed application CPU time (seconds): 0.528, 3% CPU
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 libsystem_kernel.dylib 0x39b84570 read + 8
1 libcopyfile.dylib 0x39a70df4 copyfile_internal + 4616
2 libcopyfile.dylib 0x39a72196 copyfile + 3326
3 Foundation 0x32301cb4 -[NSFilesystemItemCopyOperation _handleFTSEntry:] + 384
4 Foundation 0x323014a2 -[NSDirectoryTraversalOperation main] + 334
5 Foundation 0x322af5bc -[__NSOperationInternal start] + 836
6 Foundation 0x322fdd1e -[NSFileManager copyItemAtPath:toPath:error:] + 238
7 Upgrade 0x0009f438 -[JPPAppDelegate persistentStoreCoordinator] (JPPAppDelegate.m:186)
8 Upgrade 0x0009ef30 -[JPPAppDelegate managedObjectContext] (JPPAppDelegate.m:150)
9 Upgrade 0x0009f95e -[MainScreenViewController viewDidLoad] (MainScreenViewController.m:35)
10 UIKit 0x33849590 -[UIViewController loadViewIfRequired] + 360
11 UIKit 0x338c3fb8 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 80
12 UIKit 0x338c3f5e -[UITabBarController transitionFromViewController:toViewController:] + 26
13 UIKit 0x3386e05c -[UITabBarController _setSelectedViewController:] + 292
14 UIKit 0x3386e642 -[UITabBarController _selectDefaultViewControllerIfNecessaryWithAppearanceTransitions:] + 150
15 UIKit 0x338c6ca2 -[UITabBarController viewWillAppear:] + 130
16 UIKit 0x3389130c -[UIViewController _setViewAppearState:isAnimating:] + 132
17 UIKit 0x33849e10 -[UIView(Hierarchy) _willMoveToWindow:withAncestorView:] + 504
18 UIKit 0x3382c40e -[UIView(Internal) _addSubview:positioned:relativeTo:] + 326
19 UIKit 0x3382c2be -[UIView(Hierarchy) addSubview:] + 26
20 UIKit 0x33889e46 -[UIWindow addRootViewControllerViewIfPossible] + 270
21 UIKit 0x33885ae8 -[UIWindow _setHidden:forced:] + 360
22 UIKit 0x338c71e4 -[UIWindow makeKeyAndVisible] + 56
23 Upgrade 0x0009e896 -[JPPAppDelegate initializeStoryBoardBasedOnScreenSize] (JPPAppDelegate.m:64)
24 Upgrade 0x0009e106 -[JPPAppDelegate application:didFinishLaunchingWithOptions:] (JPPAppDelegate.m:22)
25 UIKit 0x3388aad4 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 248
26 UIKit 0x3388a65e -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1186
27 UIKit 0x33882846 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 694
28 UIKit 0x3382ac34 -[UIApplication handleEvent:withNewEvent:] + 1000
29 UIKit 0x3382a6c8 -[UIApplication sendEvent:] + 68
30 UIKit 0x3382a116 _UIApplicationHandleEvent + 6150
31 GraphicsServices 0x3551a5a0 _PurpleEventCallback + 588
32 GraphicsServices 0x3551a1ce PurpleEventCallback + 30
33 CoreFoundation 0x319f7170 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
34 CoreFoundation 0x319f7112 __CFRunLoopDoSource1 + 134
35 CoreFoundation 0x319f5f94 __CFRunLoopRun + 1380
36 CoreFoundation 0x31968eb8 CFRunLoopRunSpecific + 352
37 CoreFoundation 0x31968d44 CFRunLoopRunInMode + 100
38 UIKit 0x33881480 -[UIApplication _run] + 664
39 UIKit 0x3387e2fc UIApplicationMain + 1116
40 Upgrade 0x0009e0b8 main (main.m:16)
41 libdyld.dylib 0x39accb1c start + 0
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0 libsystem_kernel.dylib 0x39b83648 kevent64 + 24
1 libdispatch.dylib 0x39abc4ec _dispatch_mgr_invoke + 792
2 libdispatch.dylib 0x39aaedf4 _dispatch_mgr_thread$VARIANT$up + 32
Thread 2 name: WebThread
Thread 2:
0 libsystem_kernel.dylib 0x39b82eb4 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x39b83048 mach_msg + 36
2 CoreFoundation 0x319f7040 __CFRunLoopServiceMachPort + 124
3 CoreFoundation 0x319f5d9e __CFRunLoopRun + 878
4 CoreFoundation 0x31968eb8 CFRunLoopRunSpecific + 352
5 CoreFoundation 0x31968d44 CFRunLoopRunInMode + 100
6 WebCore 0x3794c500 RunWebThread(void*) + 440
7 libsystem_c.dylib 0x39aec30e _pthread_start + 306
8 libsystem_c.dylib 0x39aec1d4 thread_start + 4
Unknown thread crashed with unknown flavor: 5, state_count: 1
最佳答案
您正在主线程上复制数据,这会阻塞它太久。它永远不应被阻塞 1 秒或更长时间。否则 iOS 看门狗将终止您的进程。
具体的崩溃报告显示该应用程序被杀死,因为启动时间太长:com.JonPhillips.Upgrade 无法及时启动
。
复制操作甚至从 applicationDidFinishLaunching
内部运行。看门狗计时器甚至更短以结束此方法!如果您对 WWDC session 感兴趣,请查看确切的时间安排。我不记得具体在哪个地方提到过。
如果您需要此类任务,请将它们移至后台线程。如果此任务意味着用户无法在应用程序中执行任何操作,则显示一个特定的 UI 告诉用户正在发生什么,并给出一些指示需要多长时间,例如进度条,和/或一些文本“第 1 步,共 3 步:复制数据”。
关于ios - 为什么在旧设备上首次打开时将预填充的数据库加载到核心数据时应用程序崩溃?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17871500/
我对 Swift 比较陌生。我在 pickerView 中使用 PFQuery 时遇到了问题。 我正在尝试实现一个 2 组件 pickerView,如下所示: 组件 0:组件 1 “A”:“Altiv
packageUrl="http://192.168.0.112" packageUrl_line=`grep -n "packageUrl" ${file} | head -1 | cut -d "
我遇到了一个烦人的问题。我正在做一个消息传递应用程序。在消息页面中,当用户滚动到顶部时,一旦最上面的单元格可见,它将加载更多消息以显示。因为在加载更多消息时, TableView 的位置在顶部(内容偏
可以屏蔽吗 Jsoup.connect("http://xyz.com").get().html(); 作为对网站的浏览器调用? 我尝试构建一个壁纸下载工具,但在从服务器下载页面时遇到问题。 如果我下
IntelliJ 给了我以下代码的提示: val l = List(0, "1", 2, "3") l.foreach{_ match {case xx:Int => println(xx);case
我正在尝试读取使用三个水平点表示缺失值的 excel 文件,例如... https://population.un.org/wpp/Download/Files/1_Indicators%20(Sta
我有一个 NSPopupButton,其内容绑定(bind)到 NSArray,假设该数组是 @[ @"Option 1", @"Option 2" ]; 其选择的对象绑定(bind)
大家好,我希望您能回答这个问题:) 基本上,我的index.html中有一些html 5视频,并且会自动播放背景音频。 我想发生的是在播放视频标签时将背景音频减少到50%。如果可能的话,如果我可以使用
需要一点帮助来解决这个问题。我的目标是拥有一个可执行的 jar 文件,它可以截取网页的屏幕截图,并且可以在 Windows 和 Linux 机器上运行。我尝试过使用 html2image 但 phan
我知道如何将 comboBox 值插入到 sql 中,但不知道如何在 sql 中用数字替换 comboBox 值。 这是我的组合框编码和处理按钮的一部分。 用户.java JComboBox com
我有一个像这样的 XML 片段: WEL SMIO 01/01/2015 12/31/9999 AAE 01/01/2015
好的,我知道每个人都认为 IFrame 不好,我知道这一点。但我“被要求”在极少数情况下使用一个。 所以我的问题是,当您有一个包含 IFrame 的 .aspx 页面,然后在该 IFrame 中有另一
我有一个 React 应用程序,我在其中使用 axios 库来获取一些值,并将它们设置为处于我状态的 javascript 对象数组 componentDidMount(){ axios.
我必须存储我的 HashMap通过Spring data导入数据库MySql。为了从 HashMap 检索数据,我使用键值,并且可能会发生键不存在的情况,在这种情况下,我必须避免使用 set 方法将值
我有 Size 模型,其中 value 作为字符串。我想根据 value 属性通过将其转换为十进制来排序 size。 has_many :sizes, -> {order 'value ASC'},这
嗨,我有一个 MYSQL 表,例如 PART{ part_id :long,Auto Increment parent_part_id :long root_part_id :long } 我需
我正在尝试将列名为“邮政编码”、“2010 年人口”、“Land-Sq-Mi”和“每平方英里密度”的 CSV 文件导入我的测试表,该表名为 derp--这就是我在开头使用 drop 语句的原因,这样我
我想写一个这样的存储过程: CREATE OR REPLACE FUNCTION my_function(param_1 text, param_2 text DEFAULT NULL::text)
我有一个 RecyclerView,在它之上,有一个 AdView。滚动 RecyclerView 时,我想将 Adview 留在固定位置。我该怎么做? 这是我打开应用程序时的 RecyclerVie
我有一个 UIScrollView,其中包含一个 UIView 容器,该容器包含多个 UITextField。 我想执行以下操作:如果我选择一个字段并且它位于键盘下方,则将文本字段提升到键盘上方 20
我是一名优秀的程序员,十分优秀!