Delegates i can't get around them

Hey, I'm looking for useful resources about Delegates. I understand that the delegate is sitting in the background and receiving messages when certain things happen - for example, a table cell is selected or information from a network connection is retrieved.

In particular, I would like to learn how to use delegates with multiple objects. As far as I know, specifying the same delegate for an object (for example, a table cell) will cause the same events to be triggered simultaneously for both cells. Is there something equivalent for a delegate instance for a specific object?

Thanks in advance!

+5
source share
4 answers

Cocoa . , UITableView :

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

, UITableViews, - tableView, :

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView == self.myFirstTableView) {
        // do stuff
    } else if (tableView == self.mySecondtableView) {
        // do other stuff
    }
}

}

, tag .

+6

, , , ( ).

, , tableviewcell, :

-(void) extractTextFromLabelOfTableCell:(UITableViewCell *) theCallingCell{
...
NSString *extractedText=theCallingCell.textLabel.text;
}

tableviewcell :

[delegate extractTextFromLabelOfTableCell:self];

tableviewcell , . , - .

+2

- .

, . , . - , , .

(, ), (, ), .

, , , , (, , UITableViewController), , NSIndexPath ( ) .

+1

All Articles