0

I have a UIPopoverController that has a UITableView that is populated. I am trying to pass the information from the popovercontroller to the superview. The tableview that is placed in the popovercontroller is receiving the information with the didSelectRow method but the information is not transferring to the textView placed in the superView.

Below is the code I use to try and place the selected user in the textview and underneath that is the Superview code where I try to take the string and place it into the actual field when the index is clicked. I know my issue is I am not telling my superView that the row was touched and to send that information into the field but I have searched and con not find a good explanation on how to attempt this.

If anyone has any suggestions that would be great!

thanks

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath   
    *)indexPath {

    if (indexPath){


     NSString *selectedUser = [(Tweet*)[Friend objectAtIndex:indexPath.row] 
    followingScreenName]; 


    TwitterFollowersTimline *textBox = [[TwitterFollowersTimline alloc]   
    initWithNibName:@"TwitterFollowersTimeline" bundle:[NSBundle mainBundle]];



     textBox.selectedFriend = selectedUser;


     NSLog(@"%@", selectedUser);



     [textBox release];
     textBox = nil;
     }


    }

In my SuperView

    selectedFriend = [[NSString alloc] init];
    creatTweetText.text = [NSString stringWithFormat:@"@%@", selectedFriend];
2
  • Did you cut something from this code? why in the didSelectRowAtIndexPath: method you alloc-init textBox and then release it a few lines below? And in the superview, why you alloc-init selectedFriend (which is empty at this point) and then you put this empty value in creatTweetText? everything not clear, I cannot help you, sorry.
    – viggio24
    Jul 4, 2011 at 20:41
  • sorry it wasn't clear for you to understand. I try to put just enough code in to explain the issue but not bombard a page full of unneeded code. Thanks for trying to help. I believe @brandon below has helped send me in the right direction.
    – FreeAppl3
    Jul 5, 2011 at 1:24

1 Answer 1

2

In order to pass information from the View Controller of the popover you're going to want to set up a delegate. Here's a link to Apple's documentation and also a good guide example.

https://developer.apple.com/library/content/documentation/General/Conceptual/DevPedia-CocoaCore/Delegation.html

http://iosdevelopertips.com/objective-c/the-basics-of-protocols-and-delegates.html

Essentially when you create the View Controller that houses the methods for your table view, you'll want to give it a delegate. Then once a cell is selected in your table view, you'll be able to send a call to your delegate with any information you need.

1
  • Thanks Brandon! Sounds about right! I appreciate the answer and think I might be able to do this relatively easy, quick and painless!
    – FreeAppl3
    Jul 5, 2011 at 1:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.