Objective c 复制应用程序包
我有一个cocoa包装器,它进行一些配置,然后将应用程序从其资源文件夹复制到/Applications。复印件坏了。下面是执行复制的代码Objective c 复制应用程序包,objective-c,Objective C,我有一个cocoa包装器,它进行一些配置,然后将应用程序从其资源文件夹复制到/Applications。复印件坏了。下面是执行复制的代码 -(BOOL)copyAppBundle NSError * error; BOOL isDir; //get path to application bundle NSBundle * mainBundle = [NSBundle mainBundle]; NSString * appSrcPath = [[mainBundle bundlePath]st
-(BOOL)copyAppBundle
NSError * error;
BOOL isDir;
//get path to application bundle
NSBundle * mainBundle = [NSBundle mainBundle];
NSString * appSrcPath = [[mainBundle bundlePath]stringByAppendingString:@"/Contents/Resources/Bogus.app"];
NSString * appTgtPath = @"/Application/Bogus.app";
if ([[NSFileManager defaultManager]fileExistsAtPath:appSrcPath isDirectory:&isDir])
{
//copy the bundle to /Applications
[[NSFileManager defaultManager]copyItemAtPath:appSrcPath toPath:appTgtPath error:&error];
}
//check the results
if ([[NSFileManager defaultManager]fileExistsAtPath:@"/Application/Bogus.app"])
{
appCopyResults = TRUE;
}
return appCopyResults;
副本不合格。是否有我遗漏的步骤,或者有更好的方法来做到这一点?它是如何失败的?你有错误吗?还是它什么都没做?我建议输入一些nslog,看看它在哪里打印出来。