I need help. I have a view with a tableView
, when I click a cell, it shows me the other view with a mapView
. How do you use a string with one class in another class?
Asked
Active
Viewed 994 times
0
-
see this - [iOS - Passing variable to view controller](http://stackoverflow.com/questions/11272864/ios-passing-variable-to-view-controller/11274661#11274661) – TheTiger Nov 30 '12 at 13:16
-
see this question:-http://stackoverflow.com/questions/13245100/how-to-access-first-class-method-from-second-class-in-objective-c/13245178#13245178 – Nitin Gohel Nov 30 '12 at 13:18
-
I did so, but it does not work: ( – sliwek Nov 30 '12 at 13:32
3 Answers
0
Create a @Property (nonatomaic,retain) NSString *stringToshow;
in next view and assign its value in didSelectRowAtIndexPath
delegate of UITableView
.

Mayur Birari
- 5,837
- 8
- 34
- 61

ask4asif
- 676
- 4
- 10
0
Please write in map view controller
in .h file of Map view controller
@property(nonatomic,retain)NSString* strToSend;
in .m file of Map view controller
@synthesis strToSend;
in base viewController where TableView is programmed
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
MapView* mapObj = [[MapView alloc]initWithNibName:@"MapView" bundle:nil];
mapObj.strToSend = @"Text To Send"; // you can send string to MapView controller via this string object
[self.navigationController pushViewController:mapObj animated:YES];
[mapObj release];
}

iDhaval
- 7,824
- 2
- 21
- 30
0
You have 2 way yo do this task
1. By using getter and setter property(making @property()).
2. Using NSUserDefault
Just follow my answer to get Better result

Community
- 1
- 1

Rajneesh071
- 30,846
- 15
- 61
- 74