Reputation: 871
I am doing the following:
#ViewController1.m
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSLog(@"Transferring");
guestViewController *controller = [segue destinationViewController];
[controller.label isEqualToString:self.num_value.text];
}
However when the view is loaded, the text does not run through or show up in the label. I have done this in past programs and it has worked on Xcode 4. However, for some reason in Xcode 5 it is not working for me. Is there something else that I need to implement to make this work in Xcode?
Upvotes: 0
Views: 90
Reputation: 4272
[controller.string isEqualToString:self.num_value.text];
isEquelToString
only check is controler.string
is the same or not as self.num.value.text.
- (BOOL)isEqualToString:(NSString *)aString
Returns a Boolean value that indicates whether a given string is equal to the receiver using a literal Unicode-based comparison.
Read the apple documentation
your can pass your string to the another controller like this:
In guestViewController's
h file :
@property (nonatomic, strong) NSString *theStringWhatYouWantToGet;
and in prepareForSegue
:
controller.theStringWhatYouWantToGet = self.num_value.text;
Upvotes: 0
Reputation: 1472
Add this to your guestViewController
's header file :
@property (nonatomic, strong) NSString *value;
The your prepareForSegue
method becomes something like this :
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSLog(@"Transferring");
guestViewController *controller = [segue destinationViewController];
[controller setValue : self.num_value.txt];
}
isEqualToString
is for comparison! Not to be used for assigning values.
Then in your viewDidLoad
method, add this :
[textLabel setText : value];
Upvotes: 1