【问题标题】:crash while setting value in NSUserDefaults在 NSUserDefaults 中设置值时崩溃
【发布时间】:2013-07-19 06:11:39
【问题描述】:

我有这个堆栈跟踪:

0 LiveTexOpClient 0x000b3d3a testflight_backtrace + 382
1 LiveTexOpClient 0x000b4988 TFSignalHandler + 264
2 libsystem_c.dylib 0x3c4d0e92 _sigtramp + 42
3 CoreFoundation 0x342edb4f CFBasicHashFindBucket + 1891
4 CoreFoundation 0x342edb4f CFBasicHashFindBucket + 1891
5 CoreFoundation 0x342eea8a CFDictionaryGetValue + 82
6 CoreFoundation 0x343357a6 -[CFXPreferencesPropertyListSource setValue:forKey:] + 38
7 CoreFoundation 0x34335722 _CFXPreferencesSetValue + 134
8 CoreFoundation 0x34335600 CFPreferencesSetAppValue + 40
9 Foundation 0x34c1c906 -[NSUserDefaults(NSUserDefaults) setObject:forKey:] + 82
10 LiveTexOpClient 0x0006db28 -[LTAuthorizationManager saveLatestSessionTimeStamp] (LTAuthorizationManager.m:390)
11 LiveTexOpClient 0x0002d7aa -[LTAppDelegate applicationWillResignActive:] (LTAppDelegate.m:48)
12 UIKit 0x36209fb4 -[UIApplication _deactivateForReason:notify:] + 400
13 UIKit 0x3623ff2a -[UIApplication _handleApplicationSuspend:eventInfo:] + 314
14 UIKit 0x361b61e6 -[UIApplication handleEvent:withNewEvent:] + 2458
15 UIKit 0x361b56cc -[UIApplication sendEvent:] + 72
16 UIKit 0x361b511a _UIApplicationHandleEvent + 6154
17 GraphicsServices 0x37eb85a2 _PurpleEventCallback + 590
18 GraphicsServices 0x37eb81d2 PurpleEventCallback + 34
19 CoreFoundation 0x34382172 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
20 CoreFoundation 0x34382116 __CFRunLoopDoSource1 + 138
21 CoreFoundation 0x34380f98 __CFRunLoopRun + 1384
22 CoreFoundation 0x342f3ebc CFRunLoopRunSpecific + 356
23 CoreFoundation 0x342f3d48 CFRunLoopRunInMode + 104
24 GraphicsServices 0x37eb72ea GSEventRunModal + 74
25 UIKit 0x36209300 UIApplicationMain + 1120
26 LiveTexOpClient 0x0002e144 main (main.m:14)
27 LiveTexOpClient 0x0002d28f start + 39

代码来自:

-(void)saveLatestSessionTimeStamp
{
    [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithDouble:[[NSDate date] timeIntervalSince1970]] forKey:self.savedLogin];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

崩溃仅发生在 5 台设备中的 2 台上。 它在两部 iphone (ios 6.1.3) 上得到,但没有在另一部 iphone 上得到 (同样的 ios 6.1.3!)。 谁能帮帮我?

【问题讨论】:

  • 看起来问题不在 iOS 版本中。尝试输出所有参数。
  • 另外,存储密钥的最佳做法是:#define kMyKeyName @"myKeyName",然后:... forKey: kMyKeyName
  • 您可以尝试在没有 TestFlight 的情况下进行构建——它正在替换您的信号处理程序,这使得更难看出是什么导致了原始信号。
  • 另外,只是猜测,但self.savedLogin 是零吗?因为那样就可以了。
  • userLogin 为 NIL - 排除情况。是不是因为代码在非主线程(GCD global_queue)上执行的?

标签: iphone ios objective-c


【解决方案1】:
  1. self.savedLogin 是否为零?
  2. self.savedLogin 是 NSString 吗?

【讨论】:

  • 让我补充一下,self.savedlogin 是属性列表兼容对象吗?它是否只包含属性列表兼容对象?
猜你喜欢
  • 1970-01-01
  • 2012-01-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-11-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多