I have a UILabel in Mainclass, now I want to Assign it text by Subclass function. My question detail code is available here link Now I want that when I click on any Cell of my UITableview (which is my Subclass) its text assign to UILabel in Mainview. my Code is below which I tried so for
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
NSString *cellText = selectedCell.textLabel.text;
NSLog(@"MY row Text:%@",cellText);
// Now here I don't know how we can pass this text to UILabel which is in my mainclass
}
My Below image also helpful for understanding my problem

You can pass label on to the subview class when you create it.
In the main view class declare:
Then on the .h for the subview, declare:
When the subview is created, assign the main view’s Label to the subview’s myAccessToMainLabel. Then assign the label in the subview code. You can always pass around properties in Objective-c.
Edit:
When you create the subview, assign mainLabel to subview’s reference iVar from the code that create it.For example, if the main create the subview then: