タイトルが言ったように: 私は ObjcClass を持って
-(void)test1:xxx -(void)test2:xxx argu:yyy
います。
[dispatchArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
[obj test2:xxx argu:yyy];
}];
例:
- (void)test:(NSString *)argument1 {
NSArray *dispatchArray = @[];//If the array is initialized with multiple objects
//I want each object to call the "test:" method unlike the following
// [dispatchArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
// [obj performSelector:@selector(test:) withObject:argument1];
// // or [obj test:argument1];
// }];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[_services enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL * stop) {
if ([obj respondsToSelector:_cmd]) {
[obj application:application didFinishLaunchingWithOptions:launchOptions];
}
}];
return YES;
}
このように ,UIApplicationDelegate にはいくつかのメソッドがあります ,書きたくない [obj application:application didFinishLaunchingWithOptions:launchOptions]; または[obj applicationWillResignActive:application]; どのメソッドでも、逆に [obj RespondsToSelector:_cmd] のようなメソッド、[obj invokeWithMethod:_cmd arguments:_VA_LIST] のような一般的なメソッドとして提案できることを願っています 。これらのメソッドは異なるメソッドに対して同じことを行うため、最適化できるかどうか