①Info.plistの中に <key>NSPrincipalClass</key> <string>AUDiffCustom</string> ②protocolの定義 @protocol AUDiffCustomMgr - (int)Update_BeforeUpdate:(BOOL*)isRestart; - (int)Update_AfterUpdate:(BOOL*)isRestart; ③NSBundleのロード -(void)loadAUDiffCustomBundle { NSBundle* bundle; Class principalClass; id instance; NSString* bundlePath = [[folderPath stringByAppendingPathComponent:@"CUSTOM"] stringByAppendingPathComponent:fileName]; bundle = [NSBundle bundleWithPath:bundlePath]; if ( [bundle load] == NO ) { return; } principalClass = [bundle principalClass]; if( !(principalClass && [principalClass conformsToProtocol:@protocol(AUDiffCustomMgr)]) ) { return ; } else { instance = [[principalClass alloc] init]; if ( [functionName isEqualToString:@"Update_BeforeUpdate"] ) { result = [instance Update_BeforeUpdate:&isRestart]; NSLog(@"isRestart %d",isRestart); } else if ( [functionName isEqualToString:@"Update_AfterUpdate"] ) { result = [instance Update_AfterUpdate:&isRestart]; } [instance release]; } } |