I want to add UIRefreshControl to my app which fetches the records from the database when the table is pulled down , I have done the following code but it is giving me error like
2014-08-06 12:31:56.263 QuizUsindDB[1183:60b] -[ScoreViewController readScoreFromDatabase]: unrecognized selector sent to instance 0x8d3d8e0
2014-08-06 12:31:56.266 QuizUsindDB[1183:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ScoreViewController readScoreFromDatabase]: unrecognized selector sent to instance 0x8d3d8e0'
*** First throw call stack:
(
0 CoreFoundation 0x018f81e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x016778e5 objc_exception_throw + 44
2 CoreFoundation 0x01995243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x018e850b ___forwarding___ + 1019
4 CoreFoundation 0x018e80ee _CF_forwarding_prep_0 + 14
5 libobjc.A.dylib 0x0168982b -[NSObject performSelector:withObject:] + 70
6 UIKit 0x003393b9 -[UIApplication sendAction:to:from:forEvent:] + 108
7 UIKit 0x00339345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
8 UIKit 0x0043abd1 -[UIControl sendAction:to:forEvent:] + 66
9 UIKit 0x0043afc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
10 UIKit 0x0043ac06 -[UIControl sendActionsForControlEvents:] + 48
11 UIKit 0x00a227e9 -[UIRefreshControl _setRefreshControlState:notify:] + 404
12 UIKit 0x00a22650 -[UIRefreshControl setRefreshControlState:] + 48
21 CoreFoundation 0x0195d43e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
22 CoreFoundation 0x0189e5cb __CFRunLoopRun + 1963
23 CoreFoundation 0x0189d9d3 CFRunLoopRunSpecific + 467
24 CoreFoundation 0x0189d7eb CFRunLoopRunInMode + 123
25 GraphicsServices 0x038ec5ee GSEventRunModal + 192
26 GraphicsServices 0x038ec42b GSEventRun + 104
27 UIKit 0x00337f9b UIApplicationMain + 1225
28 QuizUsindDB 0x0001038d main + 141
29 libdyld.dylib 0x01e41701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Code for UIRefreshControl is given above:
-(void)pullToRefresh
{
self.refreshControl = [[UIRefreshControl alloc] init];
self.refreshControl.tintColor = [UIColor blackColor];
[self.refreshControl addTarget:self action:#selector(readScoreFromDatabase)
forControlEvents:UIControlEventValueChanged];
[self.myTable addSubview:self.refreshControl];
[self.refreshControl endRefreshing];
}
I have called [self pullToRefresh] in viewDidLoad .
I have the above code for initializing and calling a selector to refresh the table.
I am not able to recognise the error, can anyone point me out mistake.
Change this line:
[self.refreshControl endRefreshing];
To this:
[self.refreshControl beginRefreshing];
The endRefreshing method should be called after your table view has finished reloading data where necessary.
Also, the crash log indicates that your -[ScoreViewController readScoreFromDatabase]: function doesn't exist.
Related
When i press my button, i got a error of access.
the error : Thread 1 : EXC_BAD_ACCESS(code=1,address=0xd0a937db)
TTest.h
#interface TTtest : NSObject
{
UIButton *monBouton ;
UIImage *skin;
}
- (void)initTest :(UIView*)vueDonne;
-(void)test:(id)sender;
TTest.m
- (void)initTest :(UIView*)vueDonne
{
skin = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:#"boutonG" ofType:#"png"]];
monBouton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
monBouton.frame = CGRectMake(50, 50, 45, 50);
[monBouton setImage:skin forState:UIControlStateNormal];
[monBouton addTarget:self action:#selector(test:) forControlEvents:UIControlEventTouchDown];
[vueDonne addSubview: monBouton];
}
-(void)test:(id)sender //didn't work because i have the probleme
{
NSLog(#"test clicked");
}
testViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
TTtest *test =[[TTtest alloc] init];
[test initTest:_testView]; //View of my application
}
EDIT:
If i add monBouton = [[UIButton alloc] init];
I get a problem of SIGABRT
2014-10-26 16:47:22.827 testAsk[2134:a0b] -[CALayerArray test:]: unrecognized selector sent to instance 0xa141ea0
2014-10-26 16:47:22.831 testAsk[2134:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CALayerArray test:]: unrecognized selector sent to instance 0xa141ea0'
*** First throw call stack:
(
0 CoreFoundation 0x017395e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014bc8b6 objc_exception_throw + 44
2 CoreFoundation 0x017d6903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0172990b ___forwarding___ + 1019
4 CoreFoundation 0x017294ee _CF_forwarding_prep_0 + 14
5 libobjc.A.dylib 0x014ce874 -[NSObject performSelector:withObject:withObject:] + 77
6 UIKit 0x0022c0c2 -[UIApplication sendAction:to:from:forEvent:] + 108
7 UIKit 0x0022c04e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
8 UIKit 0x003240c1 -[UIControl sendAction:to:forEvent:] + 66
9 UIKit 0x00324484 -[UIControl _sendActionsForEvents:withEvent:] + 577
10 UIKit 0x003231fd -[UIControl touchesBegan:withEvent:] + 254
11 UIKit 0x0026934b -[UIWindow _sendTouchesForEvent:] + 386
12 UIKit 0x0026a184 -[UIWindow sendEvent:] + 1232
13 UIKit 0x0023de86 -[UIApplication sendEvent:] + 242
14 UIKit 0x0022818f _UIApplicationHandleEventQueue + 11421
15 CoreFoundation 0x016c283f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
16 CoreFoundation 0x016c21cb __CFRunLoopDoSources0 + 235
17 CoreFoundation 0x016df29e __CFRunLoopRun + 910
18 CoreFoundation 0x016deac3 CFRunLoopRunSpecific + 467
19 CoreFoundation 0x016de8db CFRunLoopRunInMode + 123
20 GraphicsServices 0x0368e9e2 GSEventRunModal + 192
21 GraphicsServices 0x0368e809 GSEventRun + 104
22 UIKit 0x0022ad3b UIApplicationMain + 1225
23 testAsk 0x000027bd main + 141
24 libdyld.dylib 0x01d75725 start + 0
25 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
The reason for the crash is that test object is dealloced when it receives the button action.
TTtest *test =[[TTtest alloc] init]; //dealloced after viewDidLoad
so try to make the test a property and use self.test.
self.test =[[TTtest alloc] init];
Doesn't look like you defined the selector "test"
-(void)test: (id) sender
NSLog(#"test clicked");
}
In my iOS(Objective C) app, I am loading a UIWebView in a UIView and it just lead to the App crash when I click on a Text field in the webview, say in Google if I just touch the text field to enter some keyword the app will crash. I am able to open the webView in sample app, but it fails in my project.
I have user the strong reference for the variables. Error is:
-[__NSCFSet keyboardWillShow:]: unrecognized selector sent to instance 0x8fa0140
2014-08-25 12:15:40.626 Travelara[1263:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFSet keyboardWillShow:]: unrecognized selector sent to instance 0x8fa0140'
*** First throw call stack:
(
0 CoreFoundation 0x01c7a1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x019778e5 objc_exception_throw + 44
2 CoreFoundation 0x01d17243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01c6a50b ___forwarding___ + 1019
4 CoreFoundation 0x01c6a0ee _CF_forwarding_prep_0 + 14
5 Foundation 0x0164a049 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke + 40
6 CoreFoundation 0x01cd5f04 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
7 CoreFoundation 0x01c2defb _CFXNotificationPost + 2859
8 Foundation 0x01583e41 -[NSNotificationCenter postNotificationName:object:userInfo:] + 98
9 UIKit 0x00af1625 -[UIInputViewTransition postNotificationsForTransitionStart] + 1004
10 UIKit 0x00ae7562 -[UIPeripheralHost(UIKitInternal) executeTransition:] + 592
11 UIKit 0x00ae9a79 -[UIPeripheralHost(UIKitInternal) setInputViews:animationStyle:] + 929
12 UIKit 0x00ae9e7e -[UIPeripheralHost(UIKitInternal) setInputViews:animated:] + 72
13 UIKit 0x00ae9ec8 -[UIPeripheralHost(UIKitInternal) setInputViews:] + 67
14 UIKit 0x00ae0fb1 -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 1448
15 UIKit 0x0079d8b4 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 287
16 UIKit 0x00b0a6b5 -[UIWebBrowserView assistFormNode:] + 265
17 UIKit 0x0087e435 __47-[UIWebDocumentView(Interaction) performClick:]_block_invoke172 + 52
18 libdispatch.dylib 0x02e784d0 _dispatch_client_callout + 14
19 libdispatch.dylib 0x02e67439 _dispatch_barrier_sync_f_slow_invoke + 80
20 libdispatch.dylib 0x02e784d0 _dispatch_client_callout + 14
21 libdispatch.dylib 0x02e66726 _dispatch_main_queue_callback_4CF + 340
22 CoreFoundation 0x01cdf43e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
23 CoreFoundation 0x01c205cb __CFRunLoopRun + 1963
24 CoreFoundation 0x01c1f9d3 CFRunLoopRunSpecific + 467
25 CoreFoundation 0x01c1f7eb CFRunLoopRunInMode + 123
26 GraphicsServices 0x034145ee GSEventRunModal + 192
27 GraphicsServices 0x0341442b GSEventRun + 104
28 UIKit 0x00637f9b UIApplicationMain + 1225
29 Travelara 0x0007b34d main + 141
30 libdyld.dylib 0x030ad701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
The code I am using is:
self.webview1=[[UIWebView alloc]initWithFrame:CGRectMake (10,70,292,430)];
self.webview1.backgroundColor= [UIColor whiteColor];
self.webview1.userInteractionEnabled=true;
self.webview1.multipleTouchEnabled=true;
self.webview1.delegate=self;
[self addSubview:self.webview1];
self.url=#"https://www.google.co.in/";
self.nsurl=[NSURL URLWithString:self.url];
self.nsrequest=[NSURLRequest requestWithURL:self.nsurl];
[self.webview1 loadRequest:self.nsrequest];
Please help me to solve the issue.
although the source code is not enough to make accurate guess but looks like you defined something like
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification object:nil];
to get event event notification about keyboard display but forgot to define the functions
- (void)keyboardWillShow:(NSNotification *)aNotification {
[self performSelector:#selector(readjustWebviewScroller) withObject:nil afterDelay:0];
}
Please check.
Some one help me to fix this crash issue. I am not able to get the root cause of it.
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
[self presentViewController:picker animated:YES completion:nil];
And I am getting the below crash, not sure why,
-[ABPeoplePickerNavigationController masterViewController]: unrecognized selector sent to instance 0xdd8cd40
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ABPeoplePickerNavigationController masterViewController]: unrecognized selector sent to instance 0xdd8cd40'
*** First throw call stack:
(
0 CoreFoundation 0x03b5e5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x031f28b6 objc_exception_throw + 44
2 CoreFoundation 0x03bfb903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x03b4e90b ___forwarding___ + 1019
4 CoreFoundation 0x03b4e4ee _CF_forwarding_prep_0 + 14
5 UIKit 0x0271f544 -[UISearchDisplayController _areSearchContentsSplitViewMaster] + 63
6 UIKit 0x0271f6ac -[UISearchDisplayController _configureNewSearchBar] + 307
7 UIKit 0x0271ee63 -[UISearchDisplayController initWithSearchBar:contentsController:searchResultsTableViewStyle:] + 121
8 UIKit 0x0271ede5 -[UISearchDisplayController initWithSearchBar:contentsController:] + 55
9 AddressBookUI 0x03dffe5e -[ABMembersController contentView] + 1223
10 AddressBookUI 0x03e05d3e -[ABMembersViewController updateView] + 57
11 AddressBookUI 0x03e058b0 -[ABMembersViewController loadView] + 36
12 UIKit 0x0249d73e -[UIViewController loadViewIfRequired] + 78
13 UIKit 0x024c31a5 -[UINavigationController _layoutViewController:] + 39
14 UIKit 0x024c36bb -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 235
15 UIKit 0x024c37b3 -[UINavigationController _startTransition:fromViewController:toViewController:] + 78
16 UIKit 0x024c472c -[UINavigationController _startDeferredTransitionIfNeeded:] + 645
17 UIKit 0x024c5349 -[UINavigationController __viewWillLayoutSubviews] + 57
18 UIKit 0x025fe39d -[UILayoutContainerView layoutSubviews] + 213
19 UIKit 0x024c1592 __53-[UINavigationController setNeedsDeferredTransition:]_block_invoke + 45
20 UIKit 0x023a6d33 ___afterCACommitHandler_block_invoke + 15
21 UIKit 0x023a6cde _applyBlockToCFArrayCopiedToStack + 403
22 UIKit 0x023a6b0a _afterCACommitHandler + 532
23 CoreFoundation 0x03b2653e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
24 CoreFoundation 0x03b2648f __CFRunLoopDoObservers + 399
25 CoreFoundation 0x03b043b4 __CFRunLoopRun + 1076
26 CoreFoundation 0x03b03b33 CFRunLoopRunSpecific + 467
27 CoreFoundation 0x03b0394b CFRunLoopRunInMode + 123
28 GraphicsServices 0x04df39d7 GSEventRunModal + 192
29 GraphicsServices 0x04df37fe GSEventRun + 104
30 UIKit 0x0238a94b UIApplicationMain + 1225
31 ShowRoomPrive 0x0026dfd5 main + 181
32 ShowRoomPrive 0x00002ba5 start + 53
)
libc++abi.dylib: terminating with uncaught exception of type NSException
use below code i think you had not added delegate and may this help you..
ABPeoplePickerNavigationController *picker =
[[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
[self presentViewController:picker animated:YES completion:nil];
or go through this url its will give you step by tutorial how to use it
http://yuvarajmanickam.wordpress.com/2012/09/19/get-contact-number-from-abpeoplepickernavigationcontroller-ios-apps/
or with apple documentation it is show helpfull
https://developer.apple.com/library/ios/documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/Chapters/QuickStart.html
I have been reading lots of similar questions and answers but still don't quite understand what's going wrong here.
I'm trying to create a button to go back to the previous view but I keep getting the errors mentioned in the title. Could someone advise me what I'm doing wrong?
UIImage *image = [UIImage imageNamed:#"listbutton.png"];
UIButton *listbutton = [UIButton buttonWithType:UIButtonTypeCustom];
listbutton.bounds = CGRectMake( 0, 0, image.size.width, image.size.height );
[listbutton setImage:image forState:UIControlStateNormal];
[listbutton addTarget:self action:#selector(goBack:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:listbutton];
goBack:
- (void)goBack
{
[self.navigationController popViewControllerAnimated:YES];
}
error:
2014-01-05 22:03:13.344 tablepractice[12509:70b]
-[DetailViewController goBack:]: unrecognized selector sent to instance 0x8b72130 2014-01-05 22:03:13.348 tablepractice[12509:70b]
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DetailViewController
goBack:]: unrecognized selector sent to instance 0x8b72130'
* First throw call stack: ( 0 CoreFoundation 0x017405e4 exceptionPreprocess + 180 1 libobjc.A.dylib
0x014c38b6 objc_exception_throw + 44 2 CoreFoundation
0x017dd903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275 3
CoreFoundation 0x0173090b __forwarding + 1019
4 CoreFoundation 0x017304ee
_CF_forwarding_prep_0 + 14 5 libobjc.A.dylib 0x014d5874 -[NSObject performSelector:withObject:withObject:] + 77 6
UIKit 0x002330c2 -[UIApplication
sendAction:to:from:forEvent:] + 108 7 UIKit
0x0023304e -[UIApplication sendAction:toTarget:fromSender:forEvent:] +
61 8 UIKit 0x0032b0c1 -[UIControl
sendAction:to:forEvent:] + 66 9 UIKit
0x0032b484 -[UIControl _sendActionsForEvents:withEvent:] + 577 10
UIKit 0x0032a733 -[UIControl
touchesEnded:withEvent:] + 641 11 UIKit
0x0027051d -[UIWindow _sendTouchesForEvent:] + 852 12 UIKit
0x00271184 -[UIWindow sendEvent:] + 1232 13 UIKit
0x00244e86 -[UIApplication sendEvent:] + 242 14 UIKit
0x0022f18f _UIApplicationHandleEventQueue + 11421 15 CoreFoundation
0x016c983f CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION
+ 15 16 CoreFoundation 0x016c91cb __CFRunLoopDoSources0 + 235 17 CoreFoundation 0x016e629e __CFRunLoopRun + 910 18 CoreFoundation
0x016e5ac3 CFRunLoopRunSpecific + 467 19 CoreFoundation
0x016e58db CFRunLoopRunInMode + 123 20 GraphicsServices
0x036e59e2 GSEventRunModal + 192 21 GraphicsServices
0x036e5809 GSEventRun + 104 22 UIKit
0x00231d3b UIApplicationMain + 1225 23 tablepractice
0x0000388d main + 141 24 libdyld.dylib
0x01d7e70d start + 1 25 ???
0x00000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught
exception of type NSException
[listbutton addTarget:self action:#selector(goBack:) forControlEvents:UIControlEventTouchUpInside];
This needs to be changed to not use a colon in the selector method:
[listbutton addTarget:self action:#selector(goBack) forControlEvents:UIControlEventTouchUpInside];
A colon implies that there is a parameter and your goBack method has no parameters.
I have created an app that is running great on 5.0 and above but when I test on devices lower I have ran into a few issues that I am unsure of how to tackle and correct.
The first big issue is when saving to core data I use a error method that I believe is apples default error method that is created when you make a core data model. The app just crashes when below 5.0 but if I block out the error code everything works fine. Below is the code used to find and error and handle it.
NSError *error;
if (![managedObjectContext save:&error]) { // crash here
// This is a serious error saying the record could not be saved.
// Advise the user to restart the application
}
//crash log below
2012-05-13 10:17:22.062 PreviewMaker[41595:207] -[UIImage encodeWithCoder:]:
unrecognized selector sent to instance 0x5e7ce80
2012-05-13 10:17:22.064 PreviewMaker[41595:207] *** Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: '-[UIImage encodeWithCoder:]:
unrecognized selector sent to instance 0x5e7ce80'
*** Call stack at first throw:
(
0 CoreFoundation 0x013fc5a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0178b313 objc_exception_throw + 44
2 CoreFoundation 0x013fe0bb -[NSObject(NSObject)
doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x0136d966 ___forwarding___ + 966
4 CoreFoundation 0x0136d522 _CF_forwarding_prep_0 + 50
5 Foundation 0x00c45b3e _encodeObject + 1076
6 Foundation 0x00c50f89 +[NSKeyedArchiver
archivedDataWithRootObject:] + 206
7 CoreData 0x01122cb5 -[NSSQLiteConnection execute] +
2677
8 CoreData 0x011771d6 -[NSSQLiteConnection insertRow:]
+ 262
9 CoreData 0x01173e64 -[NSSQLConnection
performAdapterOperations:] + 180
10 CoreData 0x01173b0e -[NSSQLCore
_performChangesWithAdapterOps:] + 494
11 CoreData 0x011725ea -[NSSQLCore performChanges] + 410
12 CoreData 0x0116c038 -[NSSQLCore saveChanges:] + 216
13 CoreData 0x0112a199 -[NSSQLCore
executeRequest:withContext:error:] + 409
14 CoreData 0x011da70b -[NSPersistentStoreCoordinator
executeRequest:withContext:error:] + 3691
15 CoreData 0x01162948 -[NSManagedObjectContext save:] +
712
16 PreviewMaker 0x0000a0c0 -[MainViewController
noUploadJustSaveImage:] + 331
17 PreviewMaker 0x00009d3c -[MainViewController
UserConfirmedToSaveImage] + 756
18 UIKit 0x004774fd -[UIApplication
sendAction:to:from:forEvent:] + 119
19 UIKit 0x00507799 -[UIControl
sendAction:to:forEvent:] + 67
20 UIKit 0x00509c2b -[UIControl(Internal)
_sendActionsForEvents:withEvent:] + 527
21 UIKit 0x005087d8 -[UIControl
touchesEnded:withEvent:] + 458
22 UIKit 0x0049bded -[UIWindow _sendTouchesForEvent:]
+ 567
23 UIKit 0x0047cc37 -[UIApplication sendEvent:] + 447
24 UIKit 0x00481f2e _UIApplicationHandleEvent + 7576
25 GraphicsServices 0x01eb8992 PurpleEventCallback + 1550
26 CoreFoundation 0x013dd944
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
27 CoreFoundation 0x0133dcf7 __CFRunLoopDoSource1 + 215
28 CoreFoundation 0x0133af83 __CFRunLoopRun + 979
29 CoreFoundation 0x0133a840 CFRunLoopRunSpecific + 208
30 CoreFoundation 0x0133a761 CFRunLoopRunInMode + 97
31 GraphicsServices 0x01eb71c4 GSEventRunModal + 217
32 GraphicsServices 0x01eb7289 GSEventRun + 115
33 UIKit 0x00485c93 UIApplicationMain + 1160
34 PreviewMaker 0x00002e07 main + 121
35 PreviewMaker 0x00002d85 start + 53
)
terminate called after throwing an instance of 'NSException'
Another issue I am running into is setting tintColor on UI objects such as the UISwitch. I have a settings controller that has several UISwitches and such which just about all have a tint color set on, but once agin anything below 5.0 crashes. How can I handle the two and not have to re-write the code just to be compatible with devices below 5.0.
shineSwitch = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease];
[cell.contentView addSubview:shineSwitch];
cell.accessoryView = shineSwitch;
[shineSwitch addTarget:self action:#selector(switchChanged:)
forControlEvents:UIControlEventValueChanged];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
shineSwitch.onTintColor = [UIColor colorWithRed:0.0 green:0.61 blue:0.99 alpha:1.0];
//crash Log below
2012-05-13 10:19:45.033 PreviewMaker[41611:207] -[UISwitch setOnTintColor:]:
unrecognized selector sent to instance 0x5eab860
2012-05-13 10:19:45.034 PreviewMaker[41611:207] *** Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: '-[UISwitch setOnTintColor:]:
unrecognized selector sent to instance 0x5eab860'
*** Call stack at first throw:
(
0 CoreFoundation 0x013fc5a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0178b313 objc_exception_throw + 44
2 CoreFoundation 0x013fe0bb -[NSObject(NSObject)
doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x0136d966 ___forwarding___ + 966
4 CoreFoundation 0x0136d522 _CF_forwarding_prep_0 + 50
5 PreviewMaker 0x0000f6fb -[FlipsideViewController
tableView:cellForRowAtIndexPath:] + 1353
6 UIKit 0x004ecb98 -
[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 634
7 UIKit 0x004e24cc -
[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
8 UIKit 0x004f78cc -
[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
9 UIKit 0x004ef90c -[UITableView layoutSubviews] +
242
10 QuartzCore 0x001e2a5a -[CALayer layoutSublayers] + 181
11 QuartzCore 0x001e4ddc CALayerLayoutIfNeeded + 220
12 QuartzCore 0x0018a0b4
_ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
13 QuartzCore 0x0018b294 _ZN2CA11Transaction6commitEv +
292
14 QuartzCore 0x0018b46d
_ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
15 CoreFoundation 0x013dd89b
__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27
16 CoreFoundation 0x013726e7 __CFRunLoopDoObservers + 295
17 CoreFoundation 0x0133b1d7 __CFRunLoopRun + 1575
18 CoreFoundation 0x0133a840 CFRunLoopRunSpecific + 208
19 CoreFoundation 0x0133a761 CFRunLoopRunInMode + 97
20 GraphicsServices 0x01eb71c4 GSEventRunModal + 217
21 GraphicsServices 0x01eb7289 GSEventRun + 115
22 UIKit 0x00485c93 UIApplicationMain + 1160
23 PreviewMaker 0x00002e07 main + 121
24 PreviewMaker 0x00002d85 start + 53
)
terminate called after throwing an instance of 'NSException'
Any help would be greatly appreciated!