I am implementing an optional delegation method in the Cocoa Touch API. I would like to do this, first call the method that was called if I did not implement the delegate ... then make changes to the result ... then return my modified version.
Here is an example:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section; { /* this line: */ UIView * headerView = [someObject tableView:tableView viewForHeaderInSection:section]; [headerView setBackgroundColor:[UIColor redColor]]; return headerView; }
The marked line does not work. I could set someObject = tableView.delegate, but that just gives me infinite recursion. Is there any trick to make tableView do what it would do if the extra method were not implemented? I do not really hope, but it would be great if possible.
, , . ; . UITableView ( ), , , -delegate ( ivar, "" ), , , , , .
UITableView ( UISectionHeaderCell, ), Apple promises , . . , Apple - , .
, , , , .
respondsToSelector - , , , :)
respondsToSelector
I assume the UITableView does something like this:
if ([delegate respondsToSelector:@selector(tableView:viewForHeaderInSection:)]) { [delegate tableView:self viewForHeaderInSection:section]; } else { // Does its own thing instead }
So, I don’t think you could get the original that way.
Source: https://habr.com/ru/post/1716169/More articles:new word in interfaces in C # - c #NHibernate будет вставлять, но не обновлять после перехода на хост с общим сервером, на котором запущен mysql - mysqlHow to extract all integer values from a string using regular expression? - phpMembership Password Asp.Net Reset Without Symbols - sqlmembershipproviderPassing PHP array in SOAP call - arrayshttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1716170/iphone-which-view-controller-methods-to-use&usg=ALkJrhh-TddsNAxl4adjSwPzIw3w_dGkTAHow to see file descriptors, for example, using "lsof -l"? - unixExplicit CALayer animation not working properly - core-animationRegular expression to extract part of a URL - regexAvoid creating the same object twice when updating in JSF - jsfAll Articles