UILabel [__NSCFString set]: unrecognized selector sent to instance crash - objective-c

I am having a weird crash related to a UILabel but the crash reporting service I am using doesn't give me much help to locate it. I can't know which Controller and which UILabel is causing it. The only help I have is the following:
-[__NSCFString set]: unrecognized selector sent to instance 0x1e0958d0
0 CoreFoundation __exceptionPreprocess + 162
1 libobjc.A.dylib objc_exception_throw + 30
2 CoreFoundation -[NSObject(NSObject) doesNotRecognizeSelector:] + 170
3 CoreFoundation ___forwarding___ + 392
4 CoreFoundation _CF_forwarding_prep_0 + 24
5 UIKit -[UILabel _legacy_drawTextInRect:baselineCalculationOnly:] + 2632
6 UIKit -[UILabel _drawTextInRect:baselineCalculationOnly:] + 166
7 UIKit -[UILabel drawTextInRect:] + 450
8 UIKit -[UILabel drawRect:] + 72
9 UIKit -[UIView(CALayerDelegate) drawLayer:inContext:] + 364
10 QuartzCore -[CALayer drawInContext:] + 112
11 QuartzCore CABackingStoreUpdate_ + 1808
12 QuartzCore CA::Layer::display_() + 980
13 QuartzCore CA::Layer::display_if_needed(CA::Transaction*) + 202
14 QuartzCore CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 24
15 QuartzCore CA::Context::commit_transaction(CA::Transaction*) + 238
16 QuartzCore CA::Transaction::commit() + 316
17 QuartzCore CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 60
18 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
19 CoreFoundation __CFRunLoopDoObservers + 276
20 CoreFoundation __CFRunLoopRun + 742
21 CoreFoundation CFRunLoopRunSpecific + 356
22 CoreFoundation CFRunLoopRunInMode + 104
23 GraphicsServices GSEventRunModal + 74
24 UIKit UIApplicationMain + 1120
25 App main.m line 14
26 App start + 40
Is there anything I can find my way through this? Thanx in advance!

Even though it's an old question, for anyone that encounters a similar issue:
If you're using attributedText in your UILabel, check the attribute value types you're setting. For example:
NSString* s = #"str";
NSMutableAttributedString* as = [[NSMutableAttributedString alloc] initWithString:s];
[as addAttribute:NSForegroundColorAttributeName value:someObjectThatsNotAUIColor range:NSMakeRange(0, s.length)];
will cause the UILabel [__NSCFString set]: unrecognized selector sent to instance crash.

You could try to put this in a .h :
#interface NSString (extended)
- (void)set;
#end
And this in a .m :
#implementation NSString (extended)
- (void)set
{
NSLog(#"[NSString set] ??? impossible !!!");
}
#end
Then set a breakpoint on this method.

Search your project for " set]" then you'll probably already find it, as this is a very untypical method name. If that doesn't help, use NSLog to print out all your labels adresses to your console to find out which label is causing this. Like
for (UIView *sub in self.subviews)
if ([sub kindOfClass:[UILabel class]]) NSLog(#"%p", sub);
(code untested, correct spelling if necessary)

Related

Passing variables between view controllers using segue

I've been trying to pass variables between view controllers without much luck. I started to work backwards from the problem I was encountering but am now having problems just getting the segue to action.
Whether I perform the segue with identifier method or have it actioning from the button I am using to perform a calculation I get the below error in the debugger.
Any help would be appreciated.
2014-02-14 13:59:58.795 BatteryCalculator[6944:70b] Cannot find executable for CFBundle 0x8dbd110 </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/System/Library/AccessibilityBundles/CertUIFramework.axbundle> (not loaded)
2014-02-14 14:00:00.869 BatteryCalculator[6944:70b] -[DetectorSpacing _setViewDelegate:]: unrecognized selector sent to instance 0x8dd6ff0
2014-02-14 14:00:00.872 BatteryCalculator[6944:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DetectorSpacing _setViewDelegate:]: unrecognized selector sent to instance 0x8dd6ff0'
*** First throw call stack:
(
0 CoreFoundation 0x0173d5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014c08b6 objc_exception_throw + 44
2 CoreFoundation 0x017da903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0172d90b ___forwarding___ + 1019
4 CoreFoundation 0x0172d4ee _CF_forwarding_prep_0 + 14
5 UIKit 0x00347ecc +[UIViewController setViewController:forView:] + 40
6 UIKit 0x00342921 -[UIViewController setView:] + 511
7 Foundation 0x010edd28 _NSSetUsingKeyValueSetter + 133
8 Foundation 0x010ed253 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
9 Foundation 0x0114f70a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
10 UIKit 0x004d0a15 -[UIRuntimeOutletConnection connect] + 106
11 libobjc.A.dylib 0x014d27d2 -[NSObject performSelector:] + 62
12 CoreFoundation 0x01738b6a -[NSArray makeObjectsPerformSelector:] + 314
13 UIKit 0x004cf56e -[UINib instantiateWithOwner:options:] + 1417
14 UIKit 0x00341605 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
15 UIKit 0x00341dad -[UIViewController loadView] + 302
16 UIKit 0x003420ae -[UIViewController loadViewIfRequired] + 78
17 UIKit 0x003425b4 -[UIViewController view] + 35
18 UIKit 0x0035c3e2 -[UINavigationController _startCustomTransition:] + 778
19 UIKit 0x003690c7 -[UINavigationController _startDeferredTransitionIfNeeded:] + 688
20 UIKit 0x00369cb9 -[UINavigationController __viewWillLayoutSubviews] + 57
21 UIKit 0x004a3181 -[UILayoutContainerView layoutSubviews] + 213
22 UIKit 0x0ecdc56f -[UILayoutContainerViewAccessibility(SafeCategory) layoutSubviews] + 50
23 UIKit 0x00299267 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
24 libobjc.A.dylib 0x014d281f -[NSObject performSelector:withObject:] + 70
25 QuartzCore 0x03b4b2ea -[CALayer layoutSublayers] + 148
26 QuartzCore 0x03b3f0d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
27 QuartzCore 0x03b3ef40 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
28 QuartzCore 0x03aa6ae6 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
29 QuartzCore 0x03aa7e71 _ZN2CA11Transaction6commitEv + 393
30 QuartzCore 0x03aa8544 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
31 CoreFoundation 0x017054ce __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
32 CoreFoundation 0x0170541f __CFRunLoopDoObservers + 399
33 CoreFoundation 0x016e3344 __CFRunLoopRun + 1076
34 CoreFoundation 0x016e2ac3 CFRunLoopRunSpecific + 467
35 CoreFoundation 0x016e28db CFRunLoopRunInMode + 123
36 GraphicsServices 0x036e29e2 GSEventRunModal + 192
37 GraphicsServices 0x036e2809 GSEventRun + 104
38 UIKit 0x0022ed3b UIApplicationMain + 1225
39 BatteryCalculator 0x0000582d main + 141
40 libdyld.dylib 0x01d7b70d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
At the moment I'm not trying to pass anything, I took that code out temporarily while trying to locate the problem. All I'm doing is calling a segue with identifier and getting the crash. I've also tried just calling the segue from a button on the first view controller but the same error.
When calling the segue with code I was using:
[self performSegueWithIdentifier:#"ResultSegue" sender:sender];
Here is how I pass managedObjectContext between segues
In your class where you will pass the data use prepareForSegue call. (The assumption is this class has a variable called _managedObjectContext which can be passed along to the segue class)
Class to Segue From:
.h file:
#property (weak, nonatomic) NSManagedObjectContext *managedObjectContext;
.m file:
#synthesize managedObjectContext
The call to #synthesize will make the following:
a local variable called _managedObjectContext
a method to getManagedObjectContext
a method to setManagedObjectContext
Additionally add the following method to your class
// Pass on managedObjectContext
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// If the destination VC is able to take the setManagedObjectContext method the current objectContext will be passed along.
if ([segue.destinationViewController respondsToSelector:#selector(setManagedObjectContext:)]) {
[segue.destinationViewController performSelector:#selector(setManagedObjectContext:)
withObject:_managedObjectContext];
} else {
NSLog(#"Segue to controller [%#] that does not support passing managedObjectContext", [segue destinationViewController]);
}
}
Then in my "class" to receive the data I do:
in the .h file i have
#property (weak, nonatomic) NSManagedObjectContext *managedObjectContext;
and in the .m file i have:
#synthesize managedObjectContext;
What this does (with syntehsiation) is make a setManagedObjectContext and getManagedObjectContext call. Upon being about to segue I check to make sure the destinationController will "respond to" this method, if so the data gets set.
clear?

Tabbar of TabbarController tint color

When i used this code in iPhone 4.3 simulator , i got this error but when run it on iPhone 5 simulator ,it's worked without errors .
Code
UITabBarController *tabB = [[UITabBarController alloc] init];
tabB.tabBar.tintColor=[UIColor colorWithRed:124.0/255.0 green:150.0/255.0 blue:32.0/255.0 alpha:1.0];
tabB.tabBar.selectedImageTintColor=[UIColor colorWithRed:187.0/255.0 green:255.0/255.0 blue:38.0/255.0 alpha:1.0];
tabB.viewControllers = [NSArray arrayWithObjects:hc,bt, nil];
[self.navigationController pushViewController:tabB animated:YES];
Error
-[UITabBar setTintColor:]: unrecognized selector sent to instance 0x78787c0
2012-04-24 10:59:46.776 welcomeKidsWebsite[10357:12203] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITabBar setTintColor:]: unrecognized selector sent to instance 0x78787c0'
*** Call stack at first throw:
(
0 CoreFoundation 0x01bcd5a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x01d21313 objc_exception_throw + 44
2 CoreFoundation 0x01bcf0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x01b3e966 ___forwarding___ + 966
4 CoreFoundation 0x01b3e522 _CF_forwarding_prep_0 + 50
5 welcomeKidsWebsite 0x0005ac8e -[KidsWelcomeViewController GotoBooks:] + 622
6 UIKit 0x00e1f4fd -[UIApplication sendAction:to:from:forEvent:] + 119
7 UIKit 0x00eaf799 -[UIControl sendAction:to:forEvent:] + 67
8 UIKit 0x00eb1c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
9 UIKit 0x00eb07d8 -[UIControl touchesEnded:withEvent:] + 458
10 UIKit 0x00e43ded -[UIWindow _sendTouchesForEvent:] + 567
11 UIKit 0x00e24c37 -[UIApplication sendEvent:] + 447
12 UIKit 0x00e29f2e _UIApplicationHandleEvent + 7576
13 GraphicsServices 0x02528992 PurpleEventCallback + 1550
14 CoreFoundation 0x01bae944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
15 CoreFoundation 0x01b0ecf7 __CFRunLoopDoSource1 + 215
16 CoreFoundation 0x01b0bf83 __CFRunLoopRun + 979
17 CoreFoundation 0x01b0b840 CFRunLoopRunSpecific + 208
18 CoreFoundation 0x01b0b761 CFRunLoopRunInMode + 97
19 GraphicsServices 0x025271c4 GSEventRunModal + 217
20 GraphicsServices 0x02527289 GSEventRun + 115
21 UIKit 0x00e2dc93 UIApplicationMain + 1160
22 welcomeKidsWebsite 0x000024ac main + 188
23 welcomeKidsWebsite 0x000023e5 start + 53
A good way to make this version independent is:
if ([tabBarController.tabBar respondsToSelector:#selector(setTintColor:)]) {
[tabBarController.tabBar setTintColor:color];
}
In IOS 5 this will set the tabbar tintcolor and in lower versions it wont crash
According to the documentation tintColor is only available in iOS 5.0 and later. The clue was that the 4.3 simulator is saying unrecognized selector sent to instance which basically means the method doesn't exist.
You'll need to do one of the following:
Set your minimum required iOS to 5.0.
Only apply the tint when running on iOS 5.0 or greater.
Use an alternative method supported by both versions.
Documentation Excerpt:
tintColor
The tint color to apply to the tab bar background.
#property(nonatomic, retain) UIColor *tintColor Availability
Available in iOS 5.0 and later.
try this
tabB.tintColor=[UIColor colorWithRed:124.0/255.0 green:150.0/255.0 blue:32.0/255.0 alpha:1.0];

Why am I getting invalidArgument exception while running unit test?

Inside my Table view controller I have following method
-(BOOL)isValidCoordinate:(CLLocationCoordinate2D)coordinate
{
//This is just to make sure exception is always thrown a cut down version of method
[NSException raise:#"Invalid longitude value" format:#"Longitude of %d is invalid", coordinate.longitude];
return TRUE;
}
I am running a unit test against it and I it failing giving following exception
2011-10-04 22:58:43.380 navman2[74159:ec03] -[MapViewController isValidCoordinate:]: unrecognized selector sent to instance 0x5e20830
2011-10-04 22:58:43.382 navman2[74159:ec03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MapViewController isValidCoordinate:]: unrecognized selector sent to instance 0x5e20830'
*** Call stack at first throw:
(
0 CoreFoundation 0x00f555a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x010a9313 objc_exception_throw + 44
2 CoreFoundation 0x00f570bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00ec6966 ___forwarding___ + 966
4 CoreFoundation 0x00ec6522 _CF_forwarding_prep_0 + 50
5 navman2Tests 0x05765b41 -[navman2Tests testExceptionThrownBycoordinatesCheck] + 193
6 CoreFoundation 0x00ec5c7d __invoking___ + 29
7 CoreFoundation 0x00ec5b51 -[NSInvocation invoke] + 145
8 SenTestingKit 0x201043d2 -[SenTestCase invokeTest] + 69
9 SenTestingKit 0x20104aa7 -[SenTestCase performTest:] + 192
10 SenTestingKit 0x201041d3 -[SenTest run] + 88
11 SenTestingKit 0x20106eda -[SenTestSuite performTest:] + 115
12 SenTestingKit 0x201041d3 -[SenTest run] + 88
13 SenTestingKit 0x20106eda -[SenTestSuite performTest:] + 115
14 SenTestingKit 0x201041d3 -[SenTest run] + 88
15 SenTestingKit 0x20106eda -[SenTestSuite performTest:] + 115
16 SenTestingKit 0x201041d3 -[SenTest run] + 88
17 SenTestingKit 0x201067a4 +[SenTestProbe runTests:] + 174
18 Foundation 0x0092e79e __NSFireDelayedPerform + 441
19 CoreFoundation 0x00f368c3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
20 CoreFoundation 0x00f37e74 __CFRunLoopDoTimer + 1220
21 CoreFoundation 0x00e942c9 __CFRunLoopRun + 1817
22 CoreFoundation 0x00e93840 CFRunLoopRunSpecific + 208
23 CoreFoundation 0x00e93761 CFRunLoopRunInMode + 97
24 GraphicsServices 0x016171c4 GSEventRunModal + 217
25 GraphicsServices 0x01617289 GSEventRun + 115
26 UIKit 0x001b5c93 UIApplicationMain + 1160
27 navman2 0x000028b9 main + 121
28 navman2 0x00002835 start + 53
)
terminate called throwing an exception(gdb)
Unit test is following:
#import "navman2Tests.h"
#import "TableViewController.h"
#import "MapViewController.h"
#implementation navman2Tests
- (void)setUp
{
[super setUp];
// Set-up czode here.
}
- (void)tearDown
{
// Tear-down code here.
[super tearDown];
}
- (void) testExceptionThrownBycoordinatesCheck
{
TableViewController *newView2 =[[MapViewController alloc] init];
CLLocationCoordinate2D coordinate;
double lat = 61.2180556;
double lng = -149.9002778;
coordinate.latitude = lat;
coordinate.longitude = lng;
STAssertThrows([newView2 isValidCoordinate:coordinate],#"some text description");
[newView2 release];
}
#end
The error is that you did declare newView2 as a TableViewController not a MapViewController (which has that method), change:
TableViewController *newView2 =[[MapViewController alloc] init];
with:
MapViewController *newView2 =[[MapViewController alloc] init];
anyway I would call the variable newViewController rather than newView2 :P

JSON error on iPhone app

i am getting error when i try to run an app on my simulator.
I have copied the JSON(JSON Framework) project in my app but my simulator crashes when it compiles the below lines,(I am using iOS 4.2)
- (void)viewDidLoad {
[super viewDidLoad];
NSString *jsonString = [NSString stringWithString:#"{\"foo\": \"bar\"}"];
NSDictionary *dictionary = [jsonString JSONValue];
NSLog(#"Dictionary value for \"foo\" is \"%#\"", [dictionary objectForKey:#"foo"]);
}
ERROR:
2011-03-02 13:33:37.304 test[10918:207] -[NSCFString JSONValue]: unrecognized selector sent to instance 0x3034
2011-03-02 13:33:37.308 test[10918:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString JSONValue]: unrecognized selector sent to instance 0x3034'
*** Call stack at first throw:
(
0 CoreFoundation 0x00da7be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00efc5c2 objc_exception_throw + 47
2 CoreFoundation 0x00da96fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00d19366 ___forwarding___ + 966
4 CoreFoundation 0x00d18f22 _CF_forwarding_prep_0 + 50
5 test 0x000025d7 -[testViewController viewDidLoad] + 119
6 UIKit 0x0035e65e -[UIViewController view] + 179
7 test 0x0000237e -[testAppDelegate application:didFinishLaunchingWithOptions:] + 79
8 UIKit 0x002b11fa -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
9 UIKit 0x002b355e -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
10 UIKit 0x002bddb2 -[UIApplication handleEvent:withNewEvent:] + 1533
11 UIKit 0x002b6202 -[UIApplication sendEvent:] + 71
12 UIKit 0x002bb732 _UIApplicationHandleEvent + 7576
13 GraphicsServices 0x016dda36 PurpleEventCallback + 1550
14 CoreFoundation 0x00d89064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
15 CoreFoundation 0x00ce96f7 __CFRunLoopDoSource1 + 215
16 CoreFoundation 0x00ce6983 __CFRunLoopRun + 979
17 CoreFoundation 0x00ce6240 CFRunLoopRunSpecific + 208
18 CoreFoundation 0x00ce6161 CFRunLoopRunInMode + 97
19 UIKit 0x002b2fa8 -[UIApplication _run] + 636
20 UIKit 0x002bf42e UIApplicationMain + 1160
21 test 0x0000230c main + 102
22 test 0x0000229d start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
(gdb)
Try adding -ObjC -all_load to the OTHER_LINKER_FLAGS setting. If that is not an option, you could try to use the SBJsonParser or SBJsonWriter objects directly rather than the category methods.
Make sure that SBJSON files are being compiled!
Target->Build phases->Compile files <- check if the *.m files of SBJSON are there!
Adding -ObjC -all_load to app target->build settings ->Linking ->Other Linker Flags -> Debug worked in XCode 4.
Earlier it was crashing

can someone please explain why this keeps crashing on iOS 4.2?

The code worked in iOS 3.2 and in 4.2 it keeps crashing.
Here's the line that it crashes on.
NSArray* address = [NSArray arrayWithArray:[[[access.filteredResults objectAtIndex:[indexPath row]] addressArray] objectAtIndex:0]];
2010-11-04 12:20:03.060 ContactMapper[2211:207] -[__NSCFDictionary getObjects:range:]: unrecognized selector sent to instance 0x5648e30
2010-11-04 12:20:03.062 ContactMapper[2211:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary getObjects:range:]: unrecognized selector sent to instance 0x5648e30'
*** Call stack at first throw:
(
0 CoreFoundation 0x0117abe9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x012cf5c2 objc_exception_throw + 47
2 CoreFoundation 0x0117c6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x010ec366 ___forwarding___ + 966
4 CoreFoundation 0x010ebf22 _CF_forwarding_prep_0 + 50
5 CoreFoundation 0x01176605 -[NSArray initWithArray:range:copyItems:] + 245
6 CoreFoundation 0x010e1367 +[NSArray arrayWithArray:] + 119
7 ContactMapper 0x00003a8d -[RootViewController tableView:cellForRowAtIndexPath:] + 1333
8 UIKit 0x0033a7fa -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 634
9 UIKit 0x0033077f -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
10 UIKit 0x00345450 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
11 UIKit 0x0033d538 -[UITableView layoutSubviews] + 242
12 QuartzCore 0x01fc2451 -[CALayer layoutSublayers] + 181
13 QuartzCore 0x01fc217c CALayerLayoutIfNeeded + 220
14 UIKit 0x005c7702 -[UISplitViewController willRotateToInterfaceOrientation:duration:] + 1134
15 UIKit 0x00373df2 -[UIViewController window:willRotateToInterfaceOrientation:duration:] + 962
16 UIKit 0x002edee5 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 1783
17 UIKit 0x002e8538 -[UIWindow _setRotatableViewOrientation:duration:force:] + 89
18 UIKit 0x002eb643 -[UIWindow _updateInterfaceOrientationFromDeviceOrientation:] + 164
19 Foundation 0x000306c1 _nsnote_callback + 145
20 CoreFoundation 0x01152f99 __CFXNotificationPost_old + 745
21 CoreFoundation 0x010d233a _CFXNotificationPostNotification + 186
22 Foundation 0x00026266 -[NSNotificationCenter postNotificationName:object:userInfo:] + 134
23 UIKit 0x00477d0a -[UIDevice setOrientation:animated:] + 228
24 UIKit 0x002c9637 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 656
25 UIKit 0x002d3db2 -[UIApplication handleEvent:withNewEvent:] + 1533
26 UIKit 0x002cc202 -[UIApplication sendEvent:] + 71
27 UIKit 0x002d1732 _UIApplicationHandleEvent + 7576
28 GraphicsServices 0x01ab0a36 PurpleEventCallback + 1550
29 CoreFoundation 0x0115c064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
30 CoreFoundation 0x010bc6f7 __CFRunLoopDoSource1 + 215
31 CoreFoundation 0x010b9983 __CFRunLoopRun + 979
32 CoreFoundation 0x010b9240 CFRunLoopRunSpecific + 208
33 CoreFoundation 0x010b9161 CFRunLoopRunInMode + 97
34 UIKit 0x002c8fa8 -[UIApplication _run] + 636
35 UIKit 0x002d542e UIApplicationMain + 1160
36 ContactMapper 0x00002638 main + 102
37 ContactMapper 0x000025c9 start + 53
)
terminate called after throwing an instance of 'NSException'
At first glance, this line is your problem:
[NSArray initWithArray:range:copyItems:]
at first glance, it might be that you need indexPath.row not [indexPath row].
Because iOS 4.2 is still under NDA, we cannot talk about 4.2-specific code.
We can however, talk about 4.1 and previous.
First, you're going to go to the 4.2 diffs page after you sign into the iOS Dev Center. This will tell you what's changed in that release. Since these pages only show release to release, look at the 3.2-4.0 diffs, 4.0-4.1 and 4.1-4.2 diffs. You are looking for a change in the API for UITableView or NSArray that obviously cannot be talked about here.
Second, you're going to download the WWDC '10 session on crash reports. It's a little tedious but the hour spent learning about how to read a crash report is WELL worth it.
Hope this helps!
The error you're getting tells you that the selector getObjects:range: is being sent to an __NSCFDictionary. So clearly the following:
[[[access.filteredResults objectAtIndex:[indexPath row]] addressArray] objectAtIndex:0]
... used to return an NSArray, but is now returning an NSDictionary.
I don't know what access is so I have no idea what else to say other than you can change the line you cited as the source of the error to:
NSDictionary* address = [NSDictionary dictionaryWithDictionary:[[[access.filteredResults objectAtIndex:[indexPath row]] addressArray] objectAtIndex:0]];
Once you've done that, whatever code follows that uses address clearly needs to also change to deal with the fact that you're no longer accessing an array.
You need the new iOS CookBook code