I am fairly new to method swizzling, and I'd like to use it to troubleshoot a problem I am having that is likely the result of an errant call to NSNotificationCenter. To do this I want to swizzle to log out each call to NSNotificationCenter's postNotification methods. The problem I have is that there are two methods with the same beginning of their name (here are their would-be swizzled implementations):
- (void) xxx_postNotificationName:(nonnull NSString *)notiifcationName object:(nullable id) obj {
[self xxx_postNotificationName:notiifcationName object:obj];
}
- (void) xxx_postNotificationName:(nonnull NSString *)notificatioName object:(nullable id)obj userInfo:(nullable NSDictionary *)userInfo {
[self xxx_postNotificationName:notificatioName object:obj userInfo:userInfo];
}
How can I identify these as separate selectors with a call like the following?
SEL originalSelector = ...
Won't they both have the form?
SEL originalSelector = @selector(postNotificationName:)
What am I missing?
No. The names of the methods are postNotificationName:object:
and postNotificationName:object:userInfo:
, so they are not the same.