Problem with UITextView
Posted
by user367039
on Stack Overflow
See other posts from Stack Overflow
or by user367039
Published on 2010-06-15T08:40:55Z
Indexed on
2010/06/15
8:42 UTC
Read the original article
Hit count: 267
I have a strange problem with trying to pass a string from one viewcontroller to another view controller if the string originates from a UITextview instead of UITextfield. Both UITextview.text and UITextfield.text are of type NSString.
The following code takes either Textfield.text or Textview.text depending on the fieldType and puts it into a string called aString.
NSString *aString = [[NSString alloc] init]; if (fieldType == 3) { aString = textView.text; } else { aString = textField.text; }
When I examine aString on either cases, I can see that it has successfully assigned the text into aString.
I then pass the string to the other view controller using this code.
[delegate updateSite:aString :editedFieldKey :fieldType]; [self.navigationController popViewControllerAnimated:YES];
This works fine if aString originated from textfield.text but nothing happens except the view controller is popped if aString was from textview.text
This is the code that takes aString and does stuff with it, however it doesn't even execute the first line of code "NSLog(@"Returned object: %@, field type:%@", aString,editedFieldKey);" if aString was from textview.text Any help will be appreciated.
-(void)updateSite:(NSString *)aString :(NSString *)editedFieldKey :(int)fieldType { NSLog(@"Returned object: %@, field type:%@", aString,editedFieldKey);
switch (fieldType) {
case 0: //string
[aDiveSite setValue:aString forKey:editedFieldKey] ;
NSLog(@"String set %@",[aDiveSite valueForKey:editedFieldKey] );
break;
case 1: //int
[aDiveSite setValue:[NSNumber numberWithInt:aString.intValue] forKey:editedFieldKey];
NSLog(@"Integer set");
break;
case 2: //float
NSLog(@"Saving floating value");
[aDiveSite setValue:[NSNumber numberWithFloat:aString.floatValue] forKey:editedFieldKey];
NSLog(@"Float set");
break;
case 3: //Text view
[aDiveSite setValue:aString forKey:editedFieldKey];
NSLog(@"Textview text saved");
default:
break; } [self.tableView reloadData];
}
© Stack Overflow or respective owner