应用程序因字符串操作而崩溃

时间:2011-03-14 11:50:43

标签: iphone nsstring

我正在尝试使用以下代码检查NSDataDictionary的内容:

NSDictionary *dataDictionary = [data objectAtIndex:num];
NSString *loaddata = [dataDictionary valueForKey:@"data"];

if ([loaddata hasSuffix: @".mp3"]) {
//code          
}

应用程序每次都崩溃,我不知道为什么......

这是错误堆栈:

#0  0x0137d930 in search_method_list
#1  0x01380a99 in _class_getMethodNoSuper_nolock
#2  0x013796ee in lookUpMethod
#3  0x0137981a in _class_lookupMethodAndLoadCache
#4  0x01387aa3 in objc_msgSend
#5  0x003417fa in -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:]
#6  0x0033777f in -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:]
#7  0x0034c450 in -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:]
#8  0x00344538 in -[UITableView layoutSubviews]
#9  0x00e19451 in -[CALayer layoutSublayers]
#10 0x00e1917c in CALayerLayoutIfNeeded
#11 0x00e1237c in CA::Context::commit_transaction
#12 0x00e120d0 in CA::Transaction::commit
#13 0x00e427d5 in CA::Transaction::observer_callback
#14 0x01206fbb in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
#15 0x0119c0e7 in __CFRunLoopDoObservers
#16 0x01164bd7 in __CFRunLoopRun
#17 0x01164240 in CFRunLoopRunSpecific
#18 0x01164161 in CFRunLoopRunInMode
#19 0x01b5a268 in GSEventRunModal
#20 0x01b5a32d in GSEventRun
#21 0x002dc42e in UIApplicationMain
#22 0x000021e4 in main at main.m:14

1 个答案:

答案 0 :(得分:2)

堆栈似乎表明Objective-C运行时无法找到选择器。我的猜测是你的第二行代码集loaddata不是NSString。