1

I am trying to examine the content of a NSDataDictionary using the following code:

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

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

The app just crashes everytime and I dont know why...

This is the error stack:

#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
user591375
  • 271
  • 4
  • 11

1 Answers1

2

The stack seems to indicate that the Objective-C runtime is failing to find the selector. My guess is your second line of code sets loaddata to something other than an NSString.

Mr. Berna
  • 10,525
  • 1
  • 39
  • 42
  • Well the first time I build and run it, it runs fine. Then if I re run it it will crash. Every time I modify any part of the whole app and then run it, it runs normally the first time. THis doesnt make sense how can the app only run fine the first time...? – user591375 Mar 15 '11 at 11:10
  • Is something in your program changing the value of 'num' or 'data'? – Mr. Berna Mar 15 '11 at 20:19
  • The value of num is changed indeed. – user591375 Mar 16 '11 at 03:21
  • So the first time through, num indexes an object in data that is an NSString. The next time through num indexes an object in data that is NOT an NSString. – Mr. Berna Mar 17 '11 at 04:05
  • I fixed the problem. I was releasing the string that I allocated in the Mutable Array data. Thanks – user591375 Mar 17 '11 at 08:36