こんにちは、カスタムNSBundle
( TicketBooking.bundle ) をロードすると問題が発生し、APP がクラッシュします
( exited abnormally with signal 9: Killed: 9 EXC_CRASH (SIGKILL)
)。
最も奇妙なことは次のとおり
です。 1. iPhone 4 を Mac に接続すると、 から APP を実行し、メソッドまたはXcode
を呼び出すと、正しいデータが返され、APP は正常に動作します。
2. 次に、iPhone 4 を Mac で切断し、APP を押します。メソッドまたはで実行すると、APP はすぐにクラッシュします。[TicketBooking load]
[TicketBooking principalClass]
[TicketBooking load]
[TicketBooking principalClass]
PS:TicketBooking.bundle には 2 つのクラスしか含まれていませCO_ManageVC.h
んCO_ManageVC.m
。
CO_ManageVC.h:
#import <UIKit/UIKit.h>
@interface CO_ManageVC : UIViewController
- (NSString *)TestWithKey:(NSString *)key;
@end
CO_ManageVC.m:
- (NSString *)TestWithKey:(NSString *)key{
if ([key isEqualToString:@"tinln"])
return @"CN_North";
else {
NSLog(@"Get CONamePrefix error:Wrong key");
return nil;
}
私が電話したとき:
NSBundle *TBBundle = [NSBundle bundleWithPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/TicketBooking.bundle"]];
// NSLog(@"%@",[NSBundle allBundles]);
NSLog(@"%@",[TBBundle infoDictionary]);
if (TBBundle)
NSLog(@"打开-done");
else {
NSLog(@"打开-fail");
return;
}
NSLog(@"ready crash");
// [TBBundle load]; //disconnect and run,crash here
Class TBClass = [TBBundle principalClass]; //disconnect and run,crash here
// Class TBClass = [TBBundle classNamed:@"CO_ManageVC"]; ////disconnect and run,crash here
UIViewController *tempVC = [[TBClass alloc] init];
NSString *COStr = [tempVC performSelector:NSSelectorFromString(@"TestWithKey:") withObject:@"tinln"];
NSLog(@"data:%@",COStr); //when connect and run with xcode, NSLog return:data:CN_North
[self.navigationController pushViewController:tempVC animated:YES];
[tempVC release];