What does this assertion failure mean in a UITableViewDataSource? - objective-c

Currently following a checklists tutorial built with io6 in mind. I'm using xcode 5, ios7 sdk. The tutorial hasn't been updated for IOS7 but I didn't want to stop my learning so decided to go ahead and work with the outdated tutorial and hopefully use it as a learning experience. Using reading of official Apple docs and extensive googling as my guide along the way.
Very early I've run into an issue already and not sure what is wrong. I noticed that the autocomplete had part of the methods below crossed out (a deprecation maybe?). The issue is definitely coming from the code below because once I remove it the simulator loads the app fine.
Code causing crash:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"ChecklistItem"];
return cell;
}
Here is the stack trace:
2013-09-28 20:51:26.208 Checklists[47289:a0b] *** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2903.2/UITableView.m:6235
2013-09-28 20:51:26.218 Checklists[47289:a0b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
*** First throw call stack:
(
0 CoreFoundation 0x017335e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014b68b6 objc_exception_throw + 44
2 CoreFoundation 0x01733448 +[NSException raise:format:arguments:] + 136
3 Foundation 0x0109723e -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x00311ae5 __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke + 426
5 UIKit 0x0028af5f +[UIView(Animation) performWithoutAnimation:] + 82
6 UIKit 0x0028afa8 +[UIView(Animation) _performWithoutAnimation:] + 40
7 UIKit 0x00311936 -[UITableView _configureCellForDisplay:forIndexPath:] + 108
8 UIKit 0x00317d4d -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 442
9 UIKit 0x00317e03 -[UITableView _createPreparedCellForGlobalRow:] + 69
10 UIKit 0x002fc124 -[UITableView _updateVisibleCellsNow:] + 2378
11 UIKit 0x0030f5a5 -[UITableView layoutSubviews] + 213
12 UIKit 0x00293dd7 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
13 libobjc.A.dylib 0x014c881f -[NSObject performSelector:withObject:] + 70
14 QuartzCore 0x03aed72a -[CALayer layoutSublayers] + 148
15 QuartzCore 0x03ae1514 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
16 QuartzCore 0x03aed675 -[CALayer layoutIfNeeded] + 160
17 UIKit 0x0034eca3 -[UIViewController window:setupWithInterfaceOrientation:] + 304
18 UIKit 0x0026dd27 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 5212
19 UIKit 0x0026c8c6 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
20 UIKit 0x0026c798 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
21 UIKit 0x0026c820 -[UIWindow _setRotatableViewOrientation:duration:force:] + 67
22 UIKit 0x0026b8ba __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120
23 UIKit 0x0026b81c -[UIWindow _updateToInterfaceOrientation:duration:force:] + 400
24 UIKit 0x0026c573 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 870
25 UIKit 0x0026fb66 -[UIWindow setDelegate:] + 449
26 UIKit 0x00340dc7 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 180
27 UIKit 0x002657cc -[UIWindow addRootViewControllerViewIfPossible] + 609
28 UIKit 0x00265947 -[UIWindow _setHidden:forced:] + 312
29 UIKit 0x00265bdd -[UIWindow _orderFrontWithoutMakingKey] + 49
30 UIKit 0x0027044a -[UIWindow makeKeyAndVisible] + 65
31 UIKit 0x002238e0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1851
32 UIKit 0x00227fb8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
33 UIKit 0x0023c42c -[UIApplication handleEvent:withNewEvent:] + 3447
34 UIKit 0x0023c999 -[UIApplication sendEvent:] + 85
35 UIKit 0x00229c35 _UIApplicationHandleEvent + 736
36 GraphicsServices 0x036862eb _PurpleEventCallback + 776
37 GraphicsServices 0x03685df6 PurpleEventCallback + 46
38 CoreFoundation 0x016aedd5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
39 CoreFoundation 0x016aeb0b __CFRunLoopDoSource1 + 523
40 CoreFoundation 0x016d97ec __CFRunLoopRun + 2156
41 CoreFoundation 0x016d8b33 CFRunLoopRunSpecific + 467
42 CoreFoundation 0x016d894b CFRunLoopRunInMode + 123
43 UIKit 0x002276ed -[UIApplication _run] + 840
44 UIKit 0x0022994b UIApplicationMain + 1225
45 Checklists 0x00001b7d main + 141
46 libdyld.dylib 0x01d6f725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException

I guess you didn't set an identifier on you cell in the storyboard, and it crashes because it can't instantiate a cell with an identifier that doesn't exists

dequeueReusableCellWithIdentifier: is used to reuse table view cells. If there's not a cell to reuse, this method returns nil, and you have to manually create the table view cell and return it. When there is a table view cell which is identical to another one that was used previously, dequeueReusableCellWithIdentifier: may return a valid cell.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"ChecklistItem"];
if(!cell)
cell= [[UITableViewCell alloc]initWithStyle: UITableViewCellStyleDefault reuseIdentifier: #"ChecklistItem"];
return cell;
}

It means that
UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:
as the error message says.
dequeueReusableCellWithIdentifier: is not guaranteed to always return a cell since it may return nil.
If you are supporting iOS >= 6, change it with dequeueReusableCellWithIdentifier:forIndexPath: which will never return nil.
The documentation is pretty clear about it.
To wrap it up your code should be
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"ChecklistItem"
forIndexPath:indexPath];
/* Configure the cell here */
return cell;
}

You need to set the class as the datasource for the tableview. You can do this by control dragging from the tableview in the storyboard to the viewController icon on the bottom (far left) and click dataSource and delegate.

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?

UIAlertView crashes in iOS7

We had compiled and deployed an app in iOS 6 environment. But, now the app is getting crash in iOS 7 whenever showing an alert.
App simply getting crash in [alertView show];
But, the same app is running perfect in iOS 6.
Code for showing alert
-(void)displayAlertWithMessage:(NSString *)message withTitle:(NSString *)title andTag:(int)tag
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:message delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alertView show];
}
and calling like this
[self displayAlertWithMessage:#"Please enter valid username!" withTitle:nil andTag:1];
Here, is the crash log.
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/developer/Library/Application Support/iPhone Simulator/7.0/Applications/A0BCB945-8E4A-4D06-BEE8-240FF45ECF78/MyProject.app> (loaded)' with name '_UIModalItemAppViewController''
*** First throw call stack:
(
0 CoreFoundation 0x003176f4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x027c88b6 objc_exception_throw + 44
2 CoreFoundation 0x003174cb +[NSException raise:format:] + 139
3 UIKit 0x015d1bec -[UINib instantiateWithOwner:options:] + 951
4 UIKit 0x01444f05 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
5 UIKit 0x014456ad -[UIViewController loadView] + 302
6 UIKit 0x014459ae -[UIViewController loadViewIfRequired] + 78
7 UIKit 0x01445eb4 -[UIViewController view] + 35
8 UIKit 0x018dc9da -[_UIModalItemsCoordinator _presentingViewControllerForAlertCompatibilityCreateIfNeeded:] + 248
9 UIKit 0x018dc8dd -[_UIModalItemsCoordinator _presentingViewControllerForAlertCompatibility] + 41
10 UIKit 0x01812801 -[UIAlertView(Private) popupAlertAnimated:animationType:atOffset:] + 382
11 UIKit 0x01812c1d -[UIAlertView(Private) popupAlertAnimated:animationType:] + 56
12 UIKit 0x01817c17 -[UIAlertView showWithAnimationType:] + 48
13 UIKit 0x01817c45 -[UIAlertView show] + 41
14 MyProject 0x000330a8 -[LoginViewController displayAlertWithMessage:withTitle:andTag:] + 232
15 MyProject 0x00032e8b -[LoginViewController isValidContent] + 299
16 MyProject 0x00033136 -[LoginViewController showSetPinView] + 54
17 libobjc.A.dylib 0x027da874 -[NSObject performSelector:withObject:withObject:] + 77
18 UIKit 0x0133524c -[UIApplication sendAction:to:from:forEvent:] + 108
19 UIKit 0x013351d8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
20 UIKit 0x0142ba5d -[UIControl sendAction:to:forEvent:] + 66
21 UIKit 0x0142be20 -[UIControl _sendActionsForEvents:withEvent:] + 577
22 UIKit 0x0142b0cf -[UIControl touchesEnded:withEvent:] + 641
23 UIKit 0x0137221d -[UIWindow _sendTouchesForEvent:] + 852
24 UIKit 0x01372e84 -[UIWindow sendEvent:] + 1232
25 UIKit 0x01346b86 -[UIApplication sendEvent:] + 242
26 MyProject 0x000c2c75 -[Application sendEvent:] + 101
27 UIKit 0x0133135f _UIApplicationHandleEventQueue + 11421
28 CoreFoundation 0x002a096f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
29 CoreFoundation 0x002a02fb __CFRunLoopDoSources0 + 235
30 CoreFoundation 0x002bd3ce __CFRunLoopRun + 910
31 CoreFoundation 0x002bcbf3 CFRunLoopRunSpecific + 467
32 CoreFoundation 0x002bca0b CFRunLoopRunInMode + 123
33 GraphicsServices 0x036f0a27 GSEventRunModal + 192
34 GraphicsServices 0x036f084e GSEventRun + 104
35 UIKit 0x01333f0b UIApplicationMain + 1225
36 MyProject 0x00006612 main + 178
37 MyProject 0x00006555 start + 53
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Thanks in advance.
As per crash log it says to me "[UIViewController _loadViewFromNibNamed:bundle:]" unable to load nib file.
But, in my project I had created a category for UIViewController class and overridden the -(id)init method. Upto ios6, while showing an alert this category method is not at all executing, but from ios7 onwards overridden init() method of UIViewController.
So, I fixed this issue by adding the another validation in UIViewController category's init() method for checking the class method is UIAlertView or not, if it is UIAlertView then simply calling [super init]; instead of doing my other stuff relating to view controllers.
Sample code:
- (id)init
{
NSString *viewControllerName = [NSString stringWithFormat:#"%#",[self class]];
if([viewControllerName isEqualToString:#"UIAlertView"])
{
self = [super init];
}
else
{
// my stuff
}
return self;
}
you can test it.. try to avoid nil.. instead of that put something... like
[self displayAlertWithMessage:#"Please enter valid username!" withTitle:#"Hello" andTag:1]
and you need to release alert view so in function write release code...

CALayerInvalidGeometry'CALayerInvalidGeometry'

I'm making a tabbed view application and using CloudMade's API.
I have a working project in a single view application which I try to copy to the tabbed view one.
I copied and pasted everything, set up the project preferences and everything.
The tabbed view FirstViewController is exactly the same as the older single view app.
How ever when I run the app, I get this error:
Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer bounds contains NaN: [inf inf; nan nan]'
I tried to google but nothing came up. It's my first tabbed view app so I'm not sure if there are stuff I need to pay attention to.
I'm not even sure what code section or error report to paste here.
Any help would be appreciated!
Thanks alot!
EDIT 2: Here's the exception stack trace (I think):
2012-02-28 23:51:00.720 ParkerAssistant[1454:f803] CRASH: CALayer bounds contains NaN: [inf inf; nan nan]
2012-02-28 23:51:00.725 ParkerAssistant[1454:f803] Stack Trace: (
0 CoreFoundation 0x0156606e __exceptionPreprocess + 206
1 libobjc.A.dylib 0x01b1ad0a objc_exception_throw + 44
2 CoreFoundation 0x0150ea78 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x0150e9e9 +[NSException raise:format:] + 57
4 QuartzCore 0x001df137 _ZN2CA5Layer10set_boundsERKNS_4RectEb + 215
5 QuartzCore 0x001d52fa -[CALayer setBounds:] + 156
6 ParkerAssistant 0x0003ee9a -[RMPath recalculateGeometry] + 927
7 ParkerAssistant 0x00002f55 -[ParkerAssistantFirstViewController viewDidLoad] + 1397
8 UIKit 0x003fd64e -[UIViewController view] + 184
9 UIKit 0x00418b89 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 105
10 UIKit 0x004189bd -[UITabBarController transitionFromViewController:toViewController:] + 63
11 UIKit 0x00416f8a -[UITabBarController _setSelectedViewController:] + 339
12 UIKit 0x00416e2f -[UITabBarController setSelectedViewController:] + 169
13 UIKit 0x00414ffb -[UITabBarController _selectDefaultViewControllerIfNecessaryWithAppearanceTransitions:] + 192
14 UIKit 0x0041585a -[UITabBarController viewWillAppear:] + 148
15 UIKit 0x003fefbf -[UIViewController _setViewAppearState:isAnimating:] + 158
16 UIKit 0x003ff21b -[UIViewController __viewWillAppear:] + 62
17 UIKit 0x004000f1 -[UIViewController viewWillMoveToWindow:] + 253
18 UIKit 0x0036efec -[UIView(Hierarchy) _willMoveToWindow:withAncestorView:] + 592
19 UIKit 0x00374572 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 388
20 UIKit 0x0036e72b -[UIView(Hierarchy) addSubview:] + 56
21 UIKit 0x0035dbc2 -[UIWindow addRootViewControllerViewIfPossible] + 380
22 UIKit 0x0035dce2 -[UIWindow _setHidden:forced:] + 280
23 UIKit 0x0035dea8 -[UIWindow _orderFrontWithoutMakingKey] + 49
24 UIKit 0x00364d9a -[UIWindow makeKeyAndVisible] + 35
25 UIKit 0x00335be6 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1820
26 UIKit 0x003368a6 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 508
27 UIKit 0x00345743 -[UIApplication handleEvent:withNewEvent:] + 1027
28 UIKit 0x003461f8 -[UIApplication sendEvent:] + 68
29 UIKit 0x00339aa9 _UIApplicationHandleEvent + 8196
30 GraphicsServices 0x02398fa9 PurpleEventCallback + 1274
31 CoreFoundation 0x0153a1c5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
32 CoreFoundation 0x0149f022 __CFRunLoopDoSource1 + 146
33 CoreFoundation 0x0149d90a __CFRunLoopRun + 2218
34 CoreFoundation 0x0149cdb4 CFRunLoopRunSpecific + 212
35 CoreFoundation 0x0149cccb CFRunLoopRunInMode + 123
36 UIKit 0x003362a7 -[UIApplication _run] + 576
37 UIKit 0x00337a9b UIApplicationMain + 1175
38 ParkerAssistant 0x000024e8 main + 152
39 ParkerAssistant 0x00002445 start + 53
)
2012-02-28 23:51:00.726 ParkerAssistant[1454:f803] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer bounds contains NaN: [inf inf; nan nan]'
*** First throw call stack:
(0x1566052 0x1b1ad0a 0x150ea78 0x150e9e9 0x1df137 0x1d52fa 0x3ee9a 0x2f55 0x3fd64e 0x418b89 0x4189bd 0x416f8a 0x416e2f 0x414ffb 0x41585a 0x3fefbf 0x3ff21b 0x4000f1 0x36efec 0x374572 0x36e72b 0x35dbc2 0x35dce2 0x35dea8 0x364d9a 0x335be6 0x3368a6 0x345743 0x3461f8 0x339aa9 0x2398fa9 0x153a1c5 0x149f022 0x149d90a 0x149cdb4 0x149cccb 0x3362a7 0x337a9b 0x24e8 0x2445)
terminate called throwing an exception
EDIT 3: viewDidLoad Method:
- (void)viewDidLoad {
[super viewDidLoad];
locationManager = [[CLLocationManager alloc] init];
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.delegate = self;
[locationManager startUpdatingLocation];
id cmTilesource = [[RMCloudMadeMapSource alloc] initWithAccessKey:#"dfd3baf1ceda40ff8b4bf4b55303253d" styleNumber:1];
[[RMMapContents alloc] initWithView:mapView tilesource: cmTilesource];
tokenManager = [[TokenManager alloc] initWithApikey:#"dfd3baf1ceda40ff8b4bf4b55303253d"];
_routingManager = [[CMRoutingManager alloc] initWithMapView:mapView tokenManager:tokenManager];
_routingManager.delegate = self;
int width = self.view.frame.size.width;
int height = 64;
_rifRect = CGRectMake(0, 0, width, height);
_firCenter = CGPointMake(width/2,height/2);
route = [[RMPath alloc] initForMap:mapView];
route.lineColor = [UIColor blueColor];
route.fillColor = [UIColor clearColor];
route.lineWidth = 5;
route.scaleLineWidth = NO;
_rif = [[CMRouteInfoView alloc] init:_rifRect :nil];
_rif.center = _firCenter;
_rif.autoresizingMask = UIViewAutoresizingFlexibleWidth;
_rif.delegate = self;
}
EDIT Hi, As it seems, the tabbed view controller has nothing to do with it.
I copied it again for a new single view application, and it doesn't work again.
I should probably mention (didn't think it made any difference before) that the working app does NOT use storyboard, just a single xib file. the 2 not working (tabbed and single view) DOES
I don't even know where to start..
Thanks
The problem was that I didn't link the map outlet, mapView, to the RMMapView object in the storyboard. Now it is working.
In your -[ParkerAssistantFirstViewController viewDidLoad] method, you send the recalculateGeometry message to an instance of RMPath. RMPath then sets the bounds of a CALayer.
Looking at the exception message, we can see that RMPath is setting the bounds of the layer to the rectangle [inf inf; nan nan]. The word inf is short for “infinity”, so your rectangle's origin is at infinity. The word nan means “not-a-number”, so your rectangle's size is completely invalid. That is what CALayer is complaining about.
Looking at the variables in your first edit, I see that scale is 0. That is suspicious. If that is the zoom factor of the view, then it's probably not valid. If that is something you control, try setting it to 1 (or some other small positive number).
Have you linked the QuartzCore.framework? I'm pretty sure CALayer requires the QuartzCore. You can do this by selecting your Target --> Build Phases Tab -- Link Binary with Libraries. click the plus sign, and scroll down to the bottom and select QuartzCore to link it to your project.

xcode 'NSInvalidArgumentException', reason: '-[cure superview]: unrecognized selector sent to instance 0x4e3b7b0'

i am not sure why i am getting this error
i created a regular tab bar application
made 5 tabs (compiles and runs)
then put a tableview in one of the tabs , put the code below and i get this error
cure.h
#import <UIKit/UIKit.h>
#interface cure : UIViewController
<UITableViewDataSource, UITableViewDelegate>
{
NSArray *exercises;
}
#end
cure.m
#import "cure.h"
#implementation cure
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"cell"];
// create a cell
if ( cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:#"cell"];
}
// set the main text
cell.textLabel.text = [exercises objectAtIndex:indexPath.row];
// return the cell.
return cell;
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
exercises = [[NSArray alloc]
initWithObjects:#"An Interesting Title",
#"A Not That Interesting Title",
#"And Still Another Title", nil];
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
#end
in mainwindows.xib
i have the right tab class name "cure"
error
2011-04-29 22:22:06.446 week 3 week clear [4950:40b] -[cure superview]: unrecognized selector sent to instance 0x4e3b7b0
2011-04-29 22:22:06.451 peek 3 week clear [4950:40b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[cure superview]: unrecognized selector sent to instance 0x4e3b7b0'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dc15a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f15313 objc_exception_throw + 44
2 CoreFoundation 0x00dc30bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00d32966 ___forwarding___ + 966
4 CoreFoundation 0x00d32522 _CF_forwarding_prep_0 + 50
5 UIKit 0x002e2365 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 77
6 UIKit 0x002e0aa3 -[UIView(Hierarchy) addSubview:] + 57
7 UIKit 0x002e87c1 -[UIView initWithCoder:] + 840
8 Foundation 0x00017c24 _decodeObjectBinary + 3296
9 Foundation 0x00016d91 _decodeObject + 224
10 UIKit 0x004ac979 -[UIRuntimeConnection initWithCoder:] + 212
11 Foundation 0x00017c24 _decodeObjectBinary + 3296
12 Foundation 0x000189f5 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1354
13 Foundation 0x00019024 -[NSArray(NSArray) initWithCoder:] + 596
14 Foundation 0x00017c24 _decodeObjectBinary + 3296
15 Foundation 0x00016d91 _decodeObject + 224
16 UIKit 0x004abc36 -[UINib instantiateWithOwner:options:] + 804
17 UIKit 0x004adab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
18 UIKit 0x00363628 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
19 UIKit 0x00361134 -[UIViewController loadView] + 120
20 UIKit 0x0036100e -[UIViewController view] + 56
21 UIKit 0x00373f54 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 120
22 UIKit 0x00372aaa -[UITabBarController transitionFromViewController:toViewController:] + 64
23 UIKit 0x003748a2 -[UITabBarController _setSelectedViewController:] + 263
24 UIKit 0x00374711 -[UITabBarController _tabBarItemClicked:] + 352
25 UIKit 0x002b14fd -[UIApplication sendAction:to:from:forEvent:] + 119
26 UIKit 0x004b3ce6 -[UITabBar _sendAction:withEvent:] + 422
27 UIKit 0x002b14fd -[UIApplication sendAction:to:from:forEvent:] + 119
28 UIKit 0x00341799 -[UIControl sendAction:to:forEvent:] + 67
29 UIKit 0x00343c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
30 UIKit 0x00341750 -[UIControl sendActionsForControlEvents:] + 49
31 UIKit 0x002b14fd -[UIApplication sendAction:to:from:forEvent:] + 119
32 UIKit 0x00341799 -[UIControl sendAction:to:forEvent:] + 67
33 UIKit 0x00343c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
34 UIKit 0x003427d8 -[UIControl touchesEnded:withEvent:] + 458
35 UIKit 0x002d5ded -[UIWindow _sendTouchesForEvent:] + 567
36 UIKit 0x002b6c37 -[UIApplication sendEvent:] + 447
37 UIKit 0x002bbf2e _UIApplicationHandleEvent + 7576
38 GraphicsServices 0x01719992 PurpleEventCallback + 1550
39 CoreFoundation 0x00da2944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
40 CoreFoundation 0x00d02cf7 __CFRunLoopDoSource1 + 215
41 CoreFoundation 0x00cfff83 __CFRunLoopRun + 979
42 CoreFoundation 0x00cff840 CFRunLoopRunSpecific + 208
43 CoreFoundation 0x00cff761 CFRunLoopRunInMode + 97
44 GraphicsServices 0x017181c4 GSEventRunModal + 217
45 GraphicsServices 0x01718289 GSEventRun + 115
46 UIKit 0x002bfc93 UIApplicationMain + 1160
47 peek 3 week clear 0x00002658 main + 102
48 peek 3 week clear 0x000025e9 start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
what am i doing wrong?
thank you
You have probably assigned the "cure" class to a UIView in the "Identity" tab in Interface Builder. "cure" is a view controller, so it doesn't implement any UIView methods (such as -superview), and thus throws an exception when trying to load the nib.
Btw, you have a whole bunch of leaks in your code, please read something about memory management in Objective-C (perhaps also about Cocoa naming conventions).

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