Passing string from UISearchBar to another viewController

J-LO

I'm attempting to store the user's input from UISearchBar and then use that string in another view controller. Here's my code:

-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{

    [searchBar resignFirstResponder];

    JobDetailViewController *detail =[[JobDetailViewController alloc] init];
    [self.navigationController pushViewController:detail animated:YES];
    self.jobSearchString = self.searchBar.text;

    [detail searchMethod];

    NSLog(@"%@",self.jobSearchString);
}

I've stored the string in a text property that I've declared in my header file and I am then pushing to another controller and calling a method. Here's the next view where I attempt to use the string stored:

JobbyViewController *mainView = [[JobbyViewController alloc] init];

NSString *searchString = [self.searcherString stringByReplacingOccurrencesOfString:@" " withString:@"-"];

It keeps coming up as (null). Any ideas?

Bot

Create a @property on your JobDetailViewController and set it

-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{

    [searchBar resignFirstResponder];

    JobDetailViewController *detail =[[JobDetailViewController alloc] init];
    detail.searchString = self.searchBar.text
    [self.navigationController pushViewController:detail animated:YES];
    self.jobSearchString = self.searchBar.text;

    [detail searchMethod];

    NSLog(@"%@",self.jobSearchString);
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Passing an managedObjectContext from one ViewController to another ViewController in Swift?

From Dev

Passing Core Data attributes from viewController to another viewController

From Dev

Swift: Passing data from a tableView in a ViewController to another ViewController

From Dev

Passing data to another ViewController without moving to the ViewController

From Dev

Passing string from a function into another function

From Dev

Passing String from one class to another

From Dev

Passing a string from one activity to another

From Dev

Passing Data from ViewController to instantiated custom viewcontroller

From Dev

Passing data from MyScene to ViewController?

From Dev

How extract from UITableView data (UIImage and String) to another ViewController

From Dev

jsf passing a string made from one bean to a string in another bean

From Dev

NSMutableArray is not mutable anymore after passing it to another viewController

From Dev

Hide UISearchbar after returning from another View

From Dev

Passing String values from custom dialog to another activity

From Dev

passing string array as hidden value from one jsp to another jsp

From Dev

Passing String values from custom dialog to another activity

From Dev

Passing bidimensional String Array variable from 1 activity to another

From Dev

Passing a string argument to another string

From Dev

Updating UILabel from another ViewController

From Dev

Present TabBarController from another ViewController

From Dev

Populating UISearchBar with String from PrepareForSegue with CoreData/NSFetchedResultsController

From Dev

passing data from Custom UItableViewCell into ViewController

From Dev

passing Int (number) from tableViewCell to new ViewController

From Dev

Passing data from tableView to ViewController in Swift

From Dev

Loss of quality passing images from viewcontroller iOS

From Dev

Passing Data from TableViewCell labels to a ViewController

From Dev

Passing string array to another activity

From Dev

iOS passing string to another app

From Dev

Passing value to another ViewController upon selecting cell in UICollectionView

Related Related

  1. 1

    Passing an managedObjectContext from one ViewController to another ViewController in Swift?

  2. 2

    Passing Core Data attributes from viewController to another viewController

  3. 3

    Swift: Passing data from a tableView in a ViewController to another ViewController

  4. 4

    Passing data to another ViewController without moving to the ViewController

  5. 5

    Passing string from a function into another function

  6. 6

    Passing String from one class to another

  7. 7

    Passing a string from one activity to another

  8. 8

    Passing Data from ViewController to instantiated custom viewcontroller

  9. 9

    Passing data from MyScene to ViewController?

  10. 10

    How extract from UITableView data (UIImage and String) to another ViewController

  11. 11

    jsf passing a string made from one bean to a string in another bean

  12. 12

    NSMutableArray is not mutable anymore after passing it to another viewController

  13. 13

    Hide UISearchbar after returning from another View

  14. 14

    Passing String values from custom dialog to another activity

  15. 15

    passing string array as hidden value from one jsp to another jsp

  16. 16

    Passing String values from custom dialog to another activity

  17. 17

    Passing bidimensional String Array variable from 1 activity to another

  18. 18

    Passing a string argument to another string

  19. 19

    Updating UILabel from another ViewController

  20. 20

    Present TabBarController from another ViewController

  21. 21

    Populating UISearchBar with String from PrepareForSegue with CoreData/NSFetchedResultsController

  22. 22

    passing data from Custom UItableViewCell into ViewController

  23. 23

    passing Int (number) from tableViewCell to new ViewController

  24. 24

    Passing data from tableView to ViewController in Swift

  25. 25

    Loss of quality passing images from viewcontroller iOS

  26. 26

    Passing Data from TableViewCell labels to a ViewController

  27. 27

    Passing string array to another activity

  28. 28

    iOS passing string to another app

  29. 29

    Passing value to another ViewController upon selecting cell in UICollectionView

HotTag

Archive