<分区>
<分区>
Possible Duplicate:
Automatically close iOS Simulator when application is stopped in Xcode
如标题所说,是否可以让 Xcode 应用程序中的代码在完成后停止并关闭模拟器?我问的原因是,如果我忘记手动关闭模拟器并让 Xcode 在模拟器运行的情况下运行,Macbook 会因为运行模拟器所需的 CPU 周期而变热。
最佳答案
使用 applescript 关闭模拟器:
tell application "/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app"
quit
end tell
然后像这样从您的应用启动它:
NSString * pstrScript= @"tell application \"/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app\"\nquit\nend tell";
if(!pstrScript)
{
NSLog(@"Error ReadAlbumArtitunesOperation::runWIthParameters:: if(!pstrScript)\n");
return nil;
}
_script = [[NSAppleScript alloc] initWithSource:pstrScript];
if(!_script)
{
NSLog(@"ERROR ReadAlbumArtItunesOperation:: runWithParameters:: if(!_script)\n");
return nil;
}
NSAppleEventDescriptor* desc= [_script executeAndReturnError:&_errorInfo];
if( _errorInfo )
{
NSLog(@"Couldn't run script: err=%@",[_errorInfo description]);
}
关于ios - 从 xcode 关闭 iPhone 模拟器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11164005/