0

I'm currently writing an iPhone app that needs to pass data from a text field on the Flipside view to the Main view when the user clicks the Done button. This is the last component of a project that I am working on.

I've tried including my MainViewController.h file on my FlipsideViewController.m file, and this doesn't work. I'm currently writing in the - (IBAction)done:(id)sender portion, something like

MainController._aTextFieldOnTheMainView.text = _aTextFieldOnTheFlipsideView.text;

but I always get this error: Property '_aTextFieldOnTheMainView' not found on object of type 'MainViewController'.

What am I doing wrong?

John Riselvato
  • 12,854
  • 5
  • 62
  • 89
user74756e61
  • 221
  • 2
  • 9

1 Answers1

0

Change/remove your weak declaration of @property (weak, nonatomic) IBOutlet UILabel *aTextFieldOnTheMainView;. This causes the deallocation of the property when the flipsideview comes onto the screen.

hope this helps

G_Money
  • 318
  • 7
  • 22
  • How do I change it so that it stays allocated when flipsideview comes in? Would I change `weak` to `strong`? – user74756e61 Feb 27 '14 at 19:20
  • Actually, just tried changing `weak` to `strong` and I still get the same error. – user74756e61 Feb 27 '14 at 19:21
  • Yes, that should do the trick. For more info check out this question [link!](http://stackoverflow.com/questions/7912555/weak-and-strong-property-setter-attributes-in-objective-c) – G_Money Feb 27 '14 at 19:22
  • Except that didn't do it, sorry. – user74756e61 Feb 27 '14 at 19:24
  • And is this property connected to a textfield on the IB? – G_Money Feb 27 '14 at 19:25
  • It is a property connected to a textfield on the Main view. What's the IB? – user74756e61 Feb 27 '14 at 19:27
  • IB is Interface Builder (for storyboards or .xib) When your main view is no longer the view on screen, does the textField get deallocated? – G_Money Feb 27 '14 at 19:41
  • Ah yeah, then yes, it is connected to the interface builder (I think). This would involve control-dragging the field to the .h file, right? – user74756e61 Feb 27 '14 at 19:43
  • And how do I tell if the textField gets deallocated? – user74756e61 Feb 27 '14 at 19:43
  • well you would know if you manually deallocated it or if the main view gets deallocated. Thus causing the subviews to deallocate – G_Money Feb 27 '14 at 20:36
  • I don't understand what you mean, I guess. I didn't manually deallocate anything, so it must be happening automatically somewhere. I haven't changed much from the default settings, so it must be something that's automatically set from the beginning. Why would the main view get deallocated when the flipside view comes into play? – user74756e61 Feb 27 '14 at 20:43
  • use the delegate methods used to dismiss the flipside view controller to pass the text along (NSString). – G_Money Feb 27 '14 at 20:59
  • I haven't found a good explanation of the delegate method yet. It all goes over my head. Sorry! – user74756e61 Feb 27 '14 at 21:17