0

I have view a that has a table cell and a save button.

If I touch the table cell, a new navigation view slides in (view b). In the view b, I have one UITextView where I type all the context I need save. And of course there is 'back' button on the top left side of the 'view b'.

'view a' has a save button, it wants save content of the textView from 'view b' that I typed in. Saving is done on 'view a' not 'view b' since actually there are other information need to be saved on 'view a' as well.

To do that, when I finish typing something into the textView of 'view b' and come back to 'view a'(back button or done button), instead of get vaporized, the content in the text view should be delivered somehow back to the ' view a' so as to be saved when I press save button.

how should I do? ( I spent almost a whole day to figure this out..)

so far I'm thinking of.. ?? = self.textView.text; at viewWillDisappear in 'view b'

many thanks.

bicbac
  • 435
  • 1
  • 9
  • 20

1 Answers1

1

use delegates of TextView and save its data just when it finished editing to dalegete class's string variable and then save it from class 1

here is the delegate method

- (void)textViewDidEndEditing:(UITextView *)textView 

{

     delegateObject.string=textView.text;
     //save to delegate class's string 

}

make sure you first initialized the string of delegate class...

Ben
  • 967
  • 3
  • 9
  • 23
Ranjeet Sajwan
  • 1,925
  • 2
  • 28
  • 60
  • thanks for the tip Ranjeet sajwan. I think I can do the delegate part, but how can I save it from class 1? how does it connected? delegate class is the one that has textView right? – bicbac Oct 15 '10 at 09:00
  • NO..i mean delegate class has just that string.... see i have edited my answer.. actually the delegate class loaded first and keep till end.... you have to make object of it and access the string from there similar as you access a string – Ranjeet Sajwan Oct 15 '10 at 09:01
  • god I think I have to familiar with delegate class...seems like work as data bridge...is the 'delegate class' my AddDelegate.h/m files.? – bicbac Oct 15 '10 at 09:13
  • thanks.I made NSString at my delegate class(textViewString). then I import the delegate class from the class that has textView. then MyAppDelegate *delegateObject = [[MyAppDelegate alloc] init]; delegateObject.textViewString = textView4Note.text; so I successfully hand over data from the textview to delegate class string. The problem is when I try save at 'view a'. I imported delegate class again and init it with same code I used above. Then I tried to use it->NSString *tempString4Save= delegateObject.textViewString; it is not working. – bicbac Oct 15 '10 at 10:59
  • Simply put, textVIew-> delegate class is ok but delegate class->another class does not seem to be working – bicbac Oct 15 '10 at 11:03
  • 1
    declare your string inMyAppDelegate.h synthesize it then initialize your textViewString in inMyAppDelegate.m method below - (void)applicationDidFinishLaunching:(UIApplication *)application { textViewString=[[NSMutableString alloc]init]; } in class 3 put following #import"MyAppDelegate.h" then make it's object in the delegate method that i provide you in my answer like following MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate]; and then appDelegate.textViewString=textView4Note.text; do same inclass 1 – Ranjeet Sajwan Oct 15 '10 at 11:12
  • Thank you Ranjeet Sajwan! Solved Out!! init delegate and 'applicationDidFinishLaunching' was very helpful. thank you again. – bicbac Oct 15 '10 at 11:39