Passing variables between view controllers using segue - crash

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?

Related

Crashing with custom navigation controller

I ran into an issue when testing my application in iOS7. The application currently runs just fine in iOS5 and iOS6. Based on the stack trace, it would appear that a private method is causing the issue.
2013-11-21 17:00:56.565 MyApp[706:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'An override of -[UINavigationController navigationBar] is returning an object that is not a kind of UINavigationBar'
*** First throw call stack:
(
0 CoreFoundation 0x0244d5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01eee8b6 objc_exception_throw + 44
2 CoreFoundation 0x0244d3bb +[NSException raise:format:] + 139
3 UIKit 0x00af796c -[UINavigationController _confirmBarAccessMethods] + 277
4 UIKit 0x00af7b19 -[UINavigationController initWithNibName:bundle:] + 271
5 MyApp 0x000b8bd8 -[CustomUINavigationController initWithNibName:bundle:] + 152
6 UIKit 0x00af77b3 -[UINavigationController initWithRootViewController:] + 86
7 MyApp 0x000b8ea1 -[CustomUINavigationController initWithRootViewController:] + 113
8 MyApp 0x0000260a -[AppDelegate application:didFinishLaunchingWithOptions:] + 666
9 UIKit 0x009c7355 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
10 UIKit 0x009c7b95 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1536
11 UIKit 0x009cc3a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
12 UIKit 0x009e087c -[UIApplication handleEvent:withNewEvent:] + 3447
13 UIKit 0x009e0de9 -[UIApplication sendEvent:] + 85
14 UIKit 0x009ce025 _UIApplicationHandleEvent + 736
15 GraphicsServices 0x0478b2f6 _PurpleEventCallback + 776
16 GraphicsServices 0x0478ae01 PurpleEventCallback + 46
17 CoreFoundation 0x023c8d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
18 CoreFoundation 0x023c8a9b __CFRunLoopDoSource1 + 523
19 CoreFoundation 0x023f377c __CFRunLoopRun + 2156
20 CoreFoundation 0x023f2ac3 CFRunLoopRunSpecific + 467
21 CoreFoundation 0x023f28db CFRunLoopRunInMode + 123
22 UIKit 0x009cbadd -[UIApplication _run] + 840
23 UIKit 0x009cdd3b UIApplicationMain + 1225
24 MyApp 0x00002337 main + 295
25 MyApp 0x00002205 start + 53
)
libc++abi.dylib: terminating with uncaught exception of type NSException
This crash happens only when testing in iOS7. It happens as soon as [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil] is called. I cannot find any information about _confirmBarAccessMethods. I assume it is a private UINavigationController method.
Here is the header file for the CustomUINavigationController class:
#import <UIKit/UIKit.h>
#import "CustomUINavigationBar.h"
#interface CustomUINavigationController : UINavigationController
{
CustomUINavigationBar *customNavigationBar;
}
#property (nonatomic, retain) UIColor *titleColor;
#end
This is the init method in which the application crashes:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; // This line causes the application to crash
if (self) {
customNavigationBar = [[CustomUINavigationBar alloc] init];
[customNavigationBar setTintColor:[UIColor colorWithWhite:0.0 alpha:1.0]];
[customNavigationBar setItems:[NSArray array] animated:NO];
[customNavigationBar setDelegate:self];
self.titleColor = [UIColor colorWithWhite:1.0 alpha:1.0];
}
return self;
}
Here is the header file for CustomNavigationBar:
#import <UIKit/UIKit.h>
#interface CustomUINavigationBar : UINavigationBar
{
UIImage *background;
}
#end
Any help would be greatly appreciated. I can provide more information if necessary.
EDIT: Added trace from suggested solution of using custom navigation bar initializer
2013-11-22 13:04:49.756 MyApp[390:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'An override of -[UINavigationController navigationBar] is returning an object that is not a kind of UINavigationBar'
*** First throw call stack:
(
0 CoreFoundation 0x0244d5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01eee8b6 objc_exception_throw + 44
2 CoreFoundation 0x0244d3bb +[NSException raise:format:] + 139
3 UIKit 0x00af796c -[UINavigationController _confirmBarAccessMethods] + 277
4 UIKit 0x00af7b19 -[UINavigationController initWithNibName:bundle:] + 271
5 MyApp 0x000b8e38 -[CustomUINavigationController initWithNibName:bundle:] + 152
6 UIKit 0x00af7815 -[UINavigationController initWithNavigationBarClass:toolbarClass:] + 52
7 MyApp 0x00002868 -[AppDelegate application:didFinishLaunchingWithOptions:] + 712
8 UIKit 0x009c7355 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
9 UIKit 0x009c7b95 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1536
10 UIKit 0x009cc3a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
11 UIKit 0x009e087c -[UIApplication handleEvent:withNewEvent:] + 3447
12 UIKit 0x009e0de9 -[UIApplication sendEvent:] + 85
13 UIKit 0x009ce025 _UIApplicationHandleEvent + 736
14 GraphicsServices 0x0478b2f6 _PurpleEventCallback + 776
15 GraphicsServices 0x0478ae01 PurpleEventCallback + 46
16 CoreFoundation 0x023c8d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
17 CoreFoundation 0x023c8a9b __CFRunLoopDoSource1 + 523
18 CoreFoundation 0x023f377c __CFRunLoopRun + 2156
19 CoreFoundation 0x023f2ac3 CFRunLoopRunSpecific + 467
20 CoreFoundation 0x023f28db CFRunLoopRunInMode + 123
21 UIKit 0x009cbadd -[UIApplication _run] + 840
22 UIKit 0x009cdd3b UIApplicationMain + 1225
23 MyApp 0x00002567 main + 295
24 MyApp 0x00002435 start + 53
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Create the navigation controller with initWithNavigationBarClass:toolbarClass: and supply your custom navigation bar class. Then perform any configuration you require on the instance created for you by the nav controller superclass.
I finally resolved the issue. CustomerUINavigationController had an override method for the navigationBar accessor. It was attempting to return a nil value. I removed this and the application compiled and ran with no issues.

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...

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

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)

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];

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).