objective c - How to pass a String from one .m to another .m file -
(sorry for bad english, IM from Germany)
I'm sorry, New am and also in Objective-C.
I have been searching for my problem for a long time also, but I could not find the answer. I believe it is very easy, but it does not work in my projects: - (
The problem is IT, I would like to use a string in two files. For example, if I create a utility app, there will be a main view and a flipside view, both have a .h file and an .m file. Now I fill Want a string in the main scene with the contents of a textfield, and And if I switch the view, the contents of the string from the main scene should be shown in a textfield on the flipside view. I have read Please help me: - ( In a short time: I want to use a string in two files, so I can work with the contents of both the files, and even in both the files. I hope someone helps me Dennis's Relationship Now if I change "all" in @ "Names" and @ NSStrings, how can I pass them to a value from the main view controller ? After When your MainViewController creates FlipSideViewController, it can give the string in question. If your FlipSideViewController and MainViewController both have a Then, when your main view controller (such as in your-viewWillAppear) starts to appear again: This is a way of doing this exactly, of course. Another method is the representative of the main controller's second aspect controller, and the second aspect controller will be to send a message when someString changes.
#import "MainViewController.h" #import "MyFirstAnnotation.h" @implementation MainViewController // Implement ViewDidLoad to perform additional setup after loading the scene, usually But at IB. - (zero) viewDidoadload [[Super Viewedload]; } - (IBAction) annosetzen: (ID) sender {CLLocationCoordinate2D coor; Coor.latitude = 54.3327162876622; Coor.longitude = 10.1518177986145; MKCoordinateSpan period; Span.latitudeDelta = 0.01; Span.longitudeDelta = 0.01; MKCoordinateRegion area; Area. Center = copper; Region.span = span; MyFast annotation * Anano = [[Myfist Annunciation Allok] Init]; [Add MapView Notation: Annual]; [MapView Set Region: Animated Area: TRUE]; // MKReverseGeocoder * revGeo = [[MKReverseGeocoder alloc] initWithCoordinate: Coir]; //revGeo.delegate = self; // [RRGO start]; } #import "MyFirst Annnotation.h" @ implementationMyFirstAnnotation- (CLLocationCoordinate2D) Coordination {CLLocationCoordinate2D coor; Coor.latitude = 54.3327162876622; Coor.longitude = 10.1518177986145; Returning kur; } - (NSString *) Title {return @ "name"; // it should be set with the main view controller} - (NSString *) subtitle {return @ "sub"; // also} @end
someString property, do so in your MainViewController:
self.flipSideViewController = [[FlipSideViewController alloc] initWithNibName: zero bundle: zero ]; Flipsideview Controller. SomeString = self.someString; [Self. Navigation controller Push ViewController: Animated FlipSide View Controller: Yes];
(self .flipSideViewController)
if {Self.someString = self.flipSideViewController.someString; Self.flipSideViewController = Zero; }
Comments
Post a Comment