我试图使用Objective-C以编程方式修改XLSX文件.
到目前为止,我只修改其中一张纸上的数据.我正在采取的步骤如下:
但是,新的XLSX文件已损坏.我正在使用GDataXML进行XML解析/编写,使用Objective-Zip进行压缩/解压缩.
我知道我创建的XML文件是正确的,因为当我手动解压缩并重新压缩损坏的XLSX文件时,它会打开而没有任何错误.我在OS X(使用Unarchiver)和Windows(使用7-Zip)上都做到了这一点.
问题出在Objective-Zip库或我使用它的方式.下面是我如何实现压缩方法:
ZipFile *zipFile = [[ZipFile alloc] initWithFileName:XLSXDocumentsFilePath mode:ZipFileModeAppend];
ZipWriteStream *stream= [zipFile writeFileInZipWithName:XLSX_WORKSHEET_XML_SUBPATH compressionLevel:ZipCompressionLevelNone];
[stream writeData:data];
[stream finishedWriting];
[zipFile close];
Run Code Online (Sandbox Code Playgroud)
我也尝试了其他的compressLevel参数,没有运气:
ZipCompressionLevelDefault
ZipCompressionLevelBest
ZipCompressionLevelFastest
Run Code Online (Sandbox Code Playgroud)
我的问题是:
从另一个问题的答案,我发现:"OOXML格式强制包中允许的唯一压缩方法是DEFLATE".
是否可以强制Objective-Zip使用DEFLATE?或者是否有一个使用DEFLATE的开源iOS压缩库?
我最近阅读了一些文档和一些博客条目Key-Value Coding,发现它非常有用.我想把它用于我的案子,但到目前为止我还没有成功.
在我的情况下,我有一个NSMutableArray包含CGPoint的转换为NSValue.我将为这个数据数组添加许多点,我想获得最小/最大x和y值.例如:
NSMutableArray *data = [[NSMutableArray alloc] init];
[data addObject:[NSValue valueWithCGPoint:CGPointMake(20.0f, 10.0f)]];
[data addObject:[NSValue valueWithCGPoint:CGPointMake(5.0f, -15.0f)]];
[data addObject:[NSValue valueWithCGPoint:CGPointMake(-5.0f, 20.0f)]];
[data addObject:[NSValue valueWithCGPoint:CGPointMake(15.0f, 30.0f)]];
// min X: -5.0, max X: 20.0
// min Y: -15.0, max Y: 30.0
Run Code Online (Sandbox Code Playgroud)
到目前为止我有两种方法.第一个是将这四个值存储在类实例变量中,并在添加新对象时将其与这些变量进行比较,并在必要时更新它们.第二个涉及for循环以找到极值,但是这种方法效率低下.
如果可能的话,我想使用KVC来完成这项任务,我相信这将是一个比我的更普遍的解决方案.在将来,我可能还需要从数组中删除一些对象,这将使我的第一个方法不适用,而我剩下的就是for-loop.
我尝试使用一些关键路径,即@"@max.x",@"@max.position.x"但我得到的只是一个NSUnknownKeyException.
是否可以安全地添加NSOperationQueue到一个NSOperation,然后将此操作添加到另一个NSOperationQueue?
这里有一些代码可视化我想要做的事情.
NSOperationQueue *mainQueue = [NSOperationQueue alloc] init];
// Here I declare some NSBlockOperation's, i.e. parseOperation1-2-3
// and also another operation called zipOperation, which includes
// an NSOperationQueue itself. This queue takes the processed (parsed) files
// and write them to a single zip file. Each operation's job is to write the data
// stream and add it to the zip file. After all operations are done,
// it closes the zip.
[zipOperation addDependency:parseOperation1]; …Run Code Online (Sandbox Code Playgroud) 我有来自Laravel的github repo的最新Laravel 4 beta 5版本.
我已经构建了一个简单的Web API,它工作正常.我想将项目复制到另一个文件夹并继续从副本处理它.但是,当我尝试时,我收到以下错误消息:
InvalidArgumentException
Driver [native] not supported.
/Users/tolga/Sites/l4api-copy/bootstrap/compiled.php
Line 10908: throw new \InvalidArgumentException("Driver [{$driver}] not supported.");
Run Code Online (Sandbox Code Playgroud)
这是我为复制项目所做的事情:
[?/Users/tolga/Sites] $ cp -R l4api l4api-copy
[?/Users/tolga/Sites] $ chmod -R 755 l4api-copy
Run Code Online (Sandbox Code Playgroud)
它没用,所以我尝试过:
[?/Users/tolga/Sites] $ chmod -R 777 l4api-copy/app/storage
Run Code Online (Sandbox Code Playgroud)
仍然没有好处,试图运行composer dump-autoload:
[?/Users/tolga/Sites] $ cd l4api-copy
[?/Users/tolga/Sites/l4api-copy] $ composer.phar dump-autoload
Generating autoload files
[?/Users/tolga/Sites/l4api-copy] $
Run Code Online (Sandbox Code Playgroud)
同样的错误.我还试图删除该app/storage文件夹并重新创建它.
[?/Users/tolga/Sites/l4api-copy] $ rm -Rf app/storage
[?/Users/tolga/Sites/l4api-copy] $ mkdir app/storage
[?/Users/tolga/Sites/l4api-copy] $ chmod -R 777 app/storage/
Run Code Online (Sandbox Code Playgroud)
这是一个全新的错误:
ErrorException
Warning: file_put_contents(/Users/tolga/Sites/l4api-copy/bootstrap/../app/storage/meta/services.json): …Run Code Online (Sandbox Code Playgroud) 我正在使用带有iPad的iPad应用程序SplitViewController.在我的DetailViewController,有一个按钮,用于显示QLPreviewController和显示文档.到目前为止一切正常,但是,当我使用Done左上角的按钮关闭预览控制器时,应用程序会抛出异常并出现以下错误:
*** Assertion failure in -[UIView layoutSublayersOfLayer:], /SourceCache/UIKit_Sim/UIKit-2380.17/UIView.m:5781
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after sending -viewDidLayoutSubviews to the view controller. DetailViewController's implementation needs to send -layoutSubviews to the view to invoke auto layout.'
*** First throw call stack: (...)
libc++abi.dylib: terminate called throwing an exception
Run Code Online (Sandbox Code Playgroud)
以下是我实现演示QLPreviewController及其委托方法的方法:
- (IBAction)previewButtonPressed:(id)sender
{
QLPreviewController *ql = [[QLPreviewController alloc] init];
ql.dataSource = self;
ql.delegate = self;
ql.currentPreviewItemIndex …Run Code Online (Sandbox Code Playgroud) objective-c ×4
ios ×3
composer-php ×1
kvc ×1
laravel ×1
laravel-4 ×1
nsoperation ×1
xlsx ×1
xml ×1
zip ×1