I'm attempting to pass the string in the itemSearch
text field from my SearchViewController
to my CriteriaViewController
. I have everything setup according to this thread: Passing Data between View Controllers. The only difference is that rather than passing a BOOL, I'm passing a string. I think my error is how I'm handling this part: controller.itemSearch == self.itemSearch.text;
Error message:
-[CriteriaViewController topViewController]: unrecognized selector sent to instance 0xa99df90
2014-04-17 17:54:20.534 Parse+Storyboard[7095:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:'-[CriteriaViewController topViewController]: unrecognized selector sent to instance 0xa99df90'
*** First throw call stack:
(
0 CoreFoundation 0x02a751e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x026338e5 objc_exception_throw + 44
2 CoreFoundation 0x02b12243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x02a6550b ___forwarding___ + 1019
4 CoreFoundation 0x02a650ee _CF_forwarding_prep_0 + 14
5 Parse+Storyboard 0x0000348e -[SearchViewController prepareForSegue:sender:] + 238
6 UIKit 0x01857efa -[UIStoryboardSegueTemplate _perform:] + 156
7 UIKit 0x0141441c -[UIViewController performSegueWithIdentifier:sender:] + 72
8 Parse+Storyboard 0x000032d1 __35-[SearchViewController nextButton:]_block_invoke + 257
9 Parse+Storyboard 0x0007a087 __40-[PFTask thenCallBackOnMainThreadAsync:]_block_invoke_2 + 241
10 libdispatch.dylib 0x036857b8 _dispatch_call_block_and_release + 15
11 libdispatch.dylib 0x0369a4d0 _dispatch_client_callout + 14
12 libdispatch.dylib 0x03688726 _dispatch_main_queue_callback_4CF + 340
13 CoreFoundation 0x02ada43e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
14 CoreFoundation 0x02a1b5cb __CFRunLoopRun + 1963
15 CoreFoundation 0x02a1a9d3 CFRunLoopRunSpecific + 467
16 CoreFoundation 0x02a1a7eb CFRunLoopRunInMode + 123
17 GraphicsServices 0x02cd25ee GSEventRunModal + 192
18 GraphicsServices 0x02cd242b GSEventRun + 104
19 UIKit 0x012f3f9b UIApplicationMain + 1225
20 Parse+Storyboard 0x000028ad main + 141
21 libdyld.dylib 0x038cf701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
SearchViewController.h:
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#import <Parse/PFCloud.h>
#import "CriteriaViewController.h"
@interface SearchViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIButton *nextButtonOutlet;
@end
SearchViewController.m:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:@"ShowCriteriaSegue"]){
UINavigationController *navController = (UINavigationController *)segue.destinationViewController;
CriteriaViewController *controller = (CriteriaViewController *)navController.topViewController;
controller.itemSearch == self.itemSearch.text;
}
}
CriteriaViewController.h
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
@interface CriteriaViewController : UIViewController
@property (nonatomic) IBOutlet UITextField *itemSearch;
@end
This line:
controller.itemSearch == self.itemSearch.text;
== is for comparison not assignment, replace it with just one equal sign.
By reading your crash message:
-[CriteriaViewController topViewController]: unrecognized selector sent to instance 0xa99df90 2014-04-17 17:54:20.534 Parse+Storyboard[7095:60b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:'-[CriteriaViewController topViewController]: unrecognized selector sent to instance 0xa99df90'
It seems like UINavigationController *navController = (UINavigationController *)segue.destinationViewController;
is returning a "CriteriaViewController" instead of a UINavigationController.
Without looking at the storyboard file, it's hard to confirm. You should check your storyboard file; the segue should be pointing to a UINavigationController which contains CriteriaViewController
User contributions licensed under CC BY-SA 3.0