iphone updating tableview after searching issue - iphone

When I search on TableView through TextDidChange which calls handleSearchTerm subroutine, it perfectly works. However, I removed TextDidChange and use SearchButtonClicked to update tableView (use same subroutine),it doesn't update TableView properly and crash when scroll(out of bound index in cellForRowAtIndex) even though datasource has been changed in subroutine. Any idea?
[78515:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFArray objectAtIndex:]: index (8) beyond bounds (8)'
*** Call stack at first throw:
(
0 CoreFoundation 0x00db8be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f0d5c2 objc_exception_throw + 47
2 CoreFoundation 0x00d71628 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x00d7159a +[NSException raise:format:] + 58
4 CoreFoundation 0x00dae8c9 _NSArrayRaiseBoundException + 121
5 CoreFoundation 0x00db0027 -[__NSCFArray objectAtIndex:] + 87
6 DrinkGuide_v1.0 0x00005d6c -[AllDrinkTableViewController tableView:cellForRowAtIndexPath:] + 371
7 UIKit 0x003357fa -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 634
8 UIKit 0x0032b77f -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
9 UIKit 0x00340450 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
10 UIKit 0x00338538 -[UITableView layoutSubviews] + 242
11 QuartzCore 0x01c76451 -[CALayer layoutSublayers] + 181
12 QuartzCore 0x01c7617c CALayerLayoutIfNeeded + 220
13 QuartzCore 0x01c6f37c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
14 QuartzCore 0x01c6f0d0 _ZN2CA11Transaction6commitEv + 292
15 QuartzCore 0x01c9f7d5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
16 CoreFoundation 0x00d99fbb __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27
17 CoreFoundation 0x00d2f0e7 __CFRunLoopDoObservers + 295
18 CoreFoundation 0x00cf7bd7 __CFRunLoopRun + 1575
19 CoreFoundation 0x00cf7240 CFRunLoopRunSpecific + 208
20 CoreFoundation 0x00cf7161 CFRunLoopRunInMode + 97
21 GraphicsServices 0x016ed268 GSEventRunModal + 217
22 GraphicsServices 0x016ed32d GSEventRun + 115
23 UIKit 0x002d042e UIApplicationMain + 1160
24 DrinkGuide_v1.0 0x0000298c main + 102
25 DrinkGuide_v1.0 0x0000291d start + 53
)
terminate called after throwing an instance of 'NSException'

I think crash is caused by cellForRowAtIndexPath, can you please post code for following methods :
cellForRowAtIndexPath
SearchButtonClicked
yourSubroutine you are calling
also mention your array or collection from which you are loading your table.
Thanks,

as per your crash log it seems you are retuning wrong no of cells in you noOfcellsInsection method. You are getting array out of bounds error.When you are doing search make a flag true and according to that flag return no of rows for the table view using your filtered array's count.

Related

SDWebImage not working on Device

Hi guys I have integrated SDWebImage for loading image from Facebook. All things works fine on simulator but when I try to run on device it give error :
B'dayReminderPlus[415:307] -[UIImageView setImageWithURL:placeholderImage:]: unrecognized selector sent to instance 0x4f7d310
2012-08-17 14:45:15.301 B'dayReminderPlus[415:307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImageView setImageWithURL:placeholderImage:]: unrecognized selector sent to instance 0x4f7d310'
*** Call stack at first throw:
(
0 CoreFoundation 0x3759dc7b __exceptionPreprocess + 114
1 libobjc.A.dylib 0x32d9bee8 objc_exception_throw + 40
2 CoreFoundation 0x3759f3e3 -[NSObject(NSObject) doesNotRecognizeSelector:] + 98
3 CoreFoundation 0x37544467 ___forwarding___ + 506
4 CoreFoundation 0x37544220 _CF_forwarding_prep_0 + 48
5 B'dayReminderPlus 0x000213e9 -[DLFirstScreenViewController tableView:cellForRowAtIndexPath:] + 5012
6 UIKit 0x359600a0 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 668
7 UIKit 0x3595fdcc -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 52
8 UIKit 0x3595db84 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1308
9 UIKit 0x3595c838 -[UITableView layoutSubviews] + 208
10 UIKit 0x358ec70c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 40
11 CoreFoundation 0x37538f79 -[NSObject(NSObject) performSelector:withObject:] + 24
12 QuartzCore 0x33d9a130 -[CALayer layoutSublayers] + 184
13 QuartzCore 0x33d99db8 CALayerLayoutIfNeeded + 200
14 QuartzCore 0x33d917c0 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 268
15 QuartzCore 0x33d91518 _ZN2CA11Transaction6commitEv + 284
16 QuartzCore 0x33dc3c28 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 88
17 CoreFoundation 0x3752a80f __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 18
18 CoreFoundation 0x3752a63d __CFRunLoopDoObservers + 500
19 CoreFoundation 0x3752199d __CFRunLoopRun + 940
20 CoreFoundation 0x3752150b CFRunLoopRunSpecific + 226
21 CoreFoundation 0x37521419 CFRunLoopRunInMode + 60
22 GraphicsServices 0x33e76d24 GSEventRunModal + 196
23 UIKit 0x3591d57c -[UIApplication _run] + 588
24 UIKit 0x3591a558 UIApplicationMain + 972
25 B'dayReminderPlus 0x00002703 main + 106
26 B'dayReminderPlus 0x00002694 start + 40
)
terminate called after throwing an instance of ‘NSException’
This crash is coming on :[cell.contactImageView setImageWithURL:[NSURL URLWithString:[[contactList objectAtIndex:indexPath.row] objectForKey:PICTURE_KEY]]placeholderImage:[UIImage imageNamed:#"placeholder.png"]];
I am not clear why this crash is happening while running APP on simulator. Any help would be appreciated. Thanx in advance.
I had this problem when running on device too. I forgot to add "-Objc" flag at "Other Linker Flags" settings.
Add Linker Flag
Open the "Build Settings" tab, in the "Linking" section, locate the
"Other Linker Flags" setting and add the "-ObjC" flag:

App Crash While hitting web Services

I have a table view in which Iam selecting a row of the table view and then it hits the web services, retrieves data and then displayed. Now this is my error log Iam getting.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-
[__NSCFData setDownloadedLogoImage:]: unrecognized selector sent to instance 0x806cf90'
*** Call stack at first throw:
(
0 CoreFoundation 0x02abdb99 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x02c0d40e objc_exception_throw + 47
2 CoreFoundation 0x02abf6ab -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x02a2f2b6 ___forwarding___ + 966
4 CoreFoundation 0x02a2ee72 _CF_forwarding_prep_0 + 50
5 FlightSearch 0x000401ef -[AirlineNames connectionDidFinishImage:] + 168
6 FlightSearch 0x0002f535 -[SAHttpManager connectionDidFinishLoading:] + 195
7 Foundation 0x001acb96 -[NSURLConnection(NSURLConnectionReallyInternal) sendDidFinishLoading] + 108
8 Foundation 0x001acaef _NSURLConnectionDidFinishLoading + 133
9 CFNetwork 0x0307172f _ZN19URLConnectionClient23_clientDidFinishLoadingEPNS_26ClientConnectionEventQueueE + 285
10 CFNetwork 0x0313cfcf _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 389
11 CFNetwork 0x03066968 _ZN19URLConnectionClient13processEventsEv + 100
12 CFNetwork 0x030667e5 _ZN17MultiplexerSource7performEv + 251
13 CoreFoundation 0x02a9efaf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
14 CoreFoundation 0x029fd39b __CFRunLoopDoSources0 + 571
15 CoreFoundation 0x029fc896 __CFRunLoopRun + 470
16 CoreFoundation 0x029fc350 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x029fc271 CFRunLoopRunInMode + 97
18 GraphicsServices 0x032b000c GSEventRunModal + 217
19 GraphicsServices 0x032b00d1 GSEventRun + 115
20 UIKit 0x00419af2 UIApplicationMain + 1160
21 FlightSearch 0x00001e86 main + 84
22 FlightSearch 0x00001e29 start + 53
23 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Kindly suggest me what should i do.
You're sending the message setDownloadedLogoImage: to an NSData object, which has no idea what to do with it! One of two things has happened:
1) You have not retained something. Take a look at whatever object you expect to call setDownloadedLogoImage on and find out where you create it - you should probably be retaining it there ;)
2) (less likely) Your code is just wrong! Add it to your question and we can take a look.

Unrecognized Selector with OHGridView

I downloaded the OHGridView hoping that it was the answer to all my problems.
https://github.com/AliSoftware/OHGridView
I did all that it said to do (add the class files, add the code, and change a few other things).
I went to build it and it crashed. I realized the lines of code why it was crashing:
((OHGridView *)self.view).rowHeight = 100;
((OHGridView *)self.view).columnsCount = 2;
Error from Console:
`-[UIView setRowHeight:]: unrecognized selector sent to instance 0x4b55110
2011-02-20 09:01:16.906 TableView[14358:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setRowHeight:]: unrecognized selector sent to instance 0x4b55110'
*** Call stack at first throw:
(
0 CoreFoundation 0x00e4dbe9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00fa25c2 objc_exception_throw + 47
2 CoreFoundation 0x00e4f6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00dbf366 ___forwarding___ + 966
4 CoreFoundation 0x00dbef22 _CF_forwarding_prep_0 + 50
5 TableView 0x00004232 -[DetailViewController viewDidLoad] + 831
6 UIKit 0x0037165e -[UIViewController view] + 179
7 UIKit 0x0036fa57 -[UIViewController contentScrollView] + 42
8 UIKit 0x00380201 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 48
9 UIKit 0x0037e831 -[UINavigationController _layoutViewController:] + 43
10 UIKit 0x0037fa86 -[UINavigationController _startTransition:fromViewController:toViewController:] + 326
11 UIKit 0x0037a606 -[UINavigationController _startDeferredTransitionIfNeeded] + 266
12 UIKit 0x0038183e -[UINavigationController pushViewController:transition:forceImmediate:] + 932
13 UIKit 0x0037a4a0 -[UINavigationController pushViewController:animated:] + 62
14 TableView 0x00002e4f -[RootViewController tableView:didSelectRowAtIndexPath:] + 681
15 UIKit 0x00339794 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1140
16 UIKit 0x0032fd50 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 219
17 Foundation 0x000427f6 __NSFireDelayedPerform + 441
18 CoreFoundation 0x00e2efe3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
19 CoreFoundation 0x00e30594 __CFRunLoopDoTimer + 1220
20 CoreFoundation 0x00d8ccc9 __CFRunLoopRun + 1817
21 CoreFoundation 0x00d8c240 CFRunLoopRunSpecific + 208
22 CoreFoundation 0x00d8c161 CFRunLoopRunInMode + 97
23 GraphicsServices 0x016ef268 GSEventRunModal + 217
24 GraphicsServices 0x016ef32d GSEventRun + 115
25 UIKit 0x002d242e UIApplicationMain + 1160
26 TableView 0x00001abc main + 102
27 TableView 0x00001a4d start + 53
)
terminate called after throwing an instance of 'NSException`
I removed them and it loaded fine but I didn't see any content.
Please help,
thanks.
I did a clone of the repository just now and then did a build and run of his example project without making any changes to the code. It ran without any warnings or errors.
You'll need to check your code wherever you made changes.
update after your comment
Unrecognized Selector often means that you have a capitalization error or that your code isn't the kind of object that you think it is.
For example: I can get almost the same error that you get if I try to call the setRowHeight: directly against a OHGridView object instead of the view property of the object, like this
((OHGridView*)self).rowHeight = 100;
((OHGridView*)self).columnsCount = 2;
So, I would check your code to make sure that your object is an OHGridView and that you are setting the rowHeight property of the view of the OHGridView.

Assertion Failure

I am developing an iPad application with SDK4.2. I have a very strange error when touching any textField in my application. The first time I touch, the keyboard is shown, but when a second touch is done in the object I obtain following trace.
And it occurs also in any TextField shown in a HTML page with a UIWebView object.
Any ideas?
I am really confused with this.. Thanks in advance!
2010-12-17 11:53:11.697 BancoPopular[48914:207] *** Assertion failure in -[UIButtonLabel setTextColor:], /SourceCache/UIKit_Sim/UIKit-1447.6.4/UILabel.m:314
2010-12-17 11:53:11.699 BancoPopular[48914:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: color'
*** Call stack at first throw:
(
0 CoreFoundation 0x01730be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x018855c2 objc_exception_throw + 47
2 CoreFoundation 0x016e9628 +[NSException raise:format:arguments:] + 136
3 Foundation 0x0013947b -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x0045d1dc -[UILabel setTextColor:] + 164
5 UIKit 0x0052177b -[UIButton layoutSubviews] + 1337
6 UIKit 0x005f3420 -[UICalloutBarButton layoutSubviews] + 54
7 QuartzCore 0x011a4451 -[CALayer layoutSublayers] + 181
8 QuartzCore 0x011a417c CALayerLayoutIfNeeded + 220
9 QuartzCore 0x011a4088 -[CALayer layoutIfNeeded] + 111
10 UIKit 0x0051f2ff -[UIButton titleLabel] + 81
11 UIKit 0x005f81d1 -[UICalloutBarButton setContentScale:] + 141
12 UIKit 0x005f6c5d -[UICalloutBar _updateVisibleItems] + 2240
13 UIKit 0x005f2970 -[UICalloutBar appear] + 211
14 UIKit 0x005eaaa9 -[UITextSelectionView showCommandsWithReplacements:] + 291
15 Foundation 0x000bd7f6 __NSFireDelayedPerform + 441
16 CoreFoundation 0x01711fe3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
17 CoreFoundation 0x01713594 __CFRunLoopDoTimer + 1220
18 CoreFoundation 0x0166fcc9 __CFRunLoopRun + 1817
19 CoreFoundation 0x0166f240 CFRunLoopRunSpecific + 208
20 CoreFoundation 0x0166f161 CFRunLoopRunInMode + 97
21 GraphicsServices 0x01e25268 GSEventRunModal + 217
22 GraphicsServices 0x01e2532d GSEventRun + 115
23 UIKit 0x0034d42e UIApplicationMain + 1160
24 BancoPopular 0x0000292e main + 84
25 BancoPopular 0x000028d1 start + 53
26 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Look carefully what exception was about. It said "reason: 'Invalid parameter not satisfying: color'", somewhere in your code, you provide wrong parameter that is supposed to be valid colors. Apparently, it seems like you use UIButton with label and set its color but not valid.
My guess is that you have some object going away somewhere, and that object contains the "color" value.
Most likely you received an autoreleased value from some call and did not retain it, so it went "poof" when the UI came up for air.

Determining where in the code an error came from - iPhone

I'm used to Java programming where an error is thrown and it tells you at what line the error was thrown from which file. But with Objective-C in XCode, I can't ever tell where the error comes from. How can I figure out where the error came from? Here is an example of a crash error:
2011-01-04 10:36:31.645 TestGA[69958:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array'
*** Call stack at first throw:
(
0 CoreFoundation 0x01121be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x012765c2 objc_exception_throw + 47
2 CoreFoundation 0x011176e5 -[__NSArrayM objectAtIndex:] + 261
3 TestGA 0x000548d8 -[S7GraphView drawRect:] + 5763
4 UIKit 0x003e16eb -[UIView(CALayerDelegate) drawLayer:inContext:] + 426
5 QuartzCore 0x00ec89e9 -[CALayer drawInContext:] + 143
6 QuartzCore 0x00ec85ef _ZL16backing_callbackP9CGContextPv + 85
7 QuartzCore 0x00ec7dea CABackingStoreUpdate + 2246
8 QuartzCore 0x00ec7134 -[CALayer _display] + 1085
9 QuartzCore 0x00ec6be4 CALayerDisplayIfNeeded + 231
10 QuartzCore 0x00eb938b _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 325
11 QuartzCore 0x00eb90d0 _ZN2CA11Transaction6commitEv + 292
12 QuartzCore 0x00ee97d5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
13 CoreFoundation 0x01102fbb __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27
14 CoreFoundation 0x010980e7 __CFRunLoopDoObservers + 295
15 CoreFoundation 0x01060bd7 __CFRunLoopRun + 1575
16 CoreFoundation 0x01060240 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x01060161 CFRunLoopRunInMode + 97
18 GraphicsServices 0x01932268 GSEventRunModal + 217
19 GraphicsServices 0x0193232d GSEventRun + 115
20 UIKit 0x003b842e UIApplicationMain + 1160
21 TestGA 0x00001cd8 main + 102
22 TestGA 0x00001c69 start + 53
23 ??? 0x00000001 0x0 + 1
So from looking at this, where is the error coming from and from which class is it coming from?
2 CoreFoundation 0x011176e5 -[__NSArrayM objectAtIndex:] + 261
An array you are using with that method is out of range.. In this case the array is empty and you try to get a value from a point that doesn't exist..
But i agree with you that it is pretty hard to find.. If you use the [white and yellow]-button next to the button you use to open the console you can check the debugger.. This way you can click on the " 2 CoreFoundation 0x011176e5 -[__NSArrayM objectAtIndex:] + 261" and see where it goes wrong..
It might be a good idea to refer to the Xcode debugging guide at Apple.com to learn more about how to debug your iOS applications.