尽管定义了处理程序内联方法,但我的 iOS 守护程序不会接收调用状态更新。在我看来,程序没有进入事件循环。你们中是否有人对 iOS 上的守护进程有任何经验,如果有,你能帮我吗?这是我得到的(用适当的编译器编译它,将它与必要的库和框架链接起来):
@interface CLAppDelegate : NSObject<UIApplicationDelegate>{
}
@end
@implementation CLAppDelegate
- (id) init
{
self = [super init];
if (self != nil)
{
NSLog(@"AppDelegate created!");
return self;
}
NSLog(@"Somehow i lost my pants.");
return nil;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSLog(@"Application launched.");
CTCallCenter* callCenter = [[CTCallCenter alloc]init];
callCenter.callEventHandler = ^(CTCall* inCTCall) {
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"CallState: %@", [inCTCall callState]);
});
};
return YES;
}
@end
int main(int argc, char* argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSLog(@"Hello iPhone! (with app delegate)");
NSString* _appdelegateclassname = NSStringFromClass([CLAppDelegate class]);
NSLog(@"AppDelegate class name: %@", _appdelegateclassname);
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://www.smr.name"]];
int retVal = UIApplicationMain(argc, argv, nil, _appdelegateclassname);
[pool release];
return retVal;
}
它编译和链接,甚至运行(OpenSSH 到 iPhone)——但从来没有显示 CallState 日志。哦,还有,是否有可能从该守护进程运行另一个应用程序(在 /User/Applications/ 文件夹中)?