我的其中一个应用程序非常偶尔会将其存储(通过设置 - >常规 - >使用 - >存储)报告为4GB,实际上,应用程序沙箱(文档,库,tmp)中所有文件的总大小平均值大约10MB左右.
我有点在我的智慧结束,并想知道是否有人经历过这样的事情.我怀疑这是与UIDocument有关的东西,但不能肯定.现在提交雷达似乎太少了.
在某些情况下,应用程序将强制系统显示一个对话框,警告用户系统存储空间不足.当发生这种情况时,似乎系统会协调它认为应用程序正在使用的存储与现实之间的差异,然后存储数量将下降到10MB左右.
这真的很奇怪.
关于我可能会看到的事情的任何想法将不胜感激.
contentsForType的实现:错误:
- (id) contentsForType: (NSString *) inTypeName
error: (NSError **) outError
{
NSFileWrapper *newWrapper, *audioFileWrapper;
NSString *audioFilename;
NSURL *newAudioWrapperURL;
newWrapper = [[[NSFileWrapper alloc] initDirectoryWithFileWrappers: nil] autorelease];
// add updated info
[newWrapper addRegularFileWithContents: [NSKeyedArchiver archivedDataWithRootObject: self.testInfo] preferredFilename: QSDocumentInfoKey];
// scan audio files and clean up where needed
for (NSDictionary *wordInfo in self.wordInfoList) {
if ((audioFilename = [wordInfo objectForKey: QSInfoAudioKey]) != nil) {
newAudioWrapperURL = [self.fileURL URLByAppendingPathComponent: audioFilename];
if ([[NSFileManager defaultManager] …Run Code Online (Sandbox Code Playgroud) 我想扩展一个Array,其函数将返回Array中所有非零项的计数.理想情况下,这适用于任何可选或非可选类型的数组.我尝试了各种无法编译,崩溃的Xcode或两者兼而有之的东西.我原以为它看起来像这样:
extension Array {
func realCount() -> Int {
var cnt = 0
for value in self {
if value != nil {
cnt++
}
}
return cnt
}
}
Run Code Online (Sandbox Code Playgroud)
斯威夫特抱怨说这T是不可转换的UInt8.或者有时MirrorDisposition或其他随机类.
所以假设有可能,有什么诀窍?
编辑:从Xcode 6 beta 5开始,现在编译,但没有给出预期的结果.if value != nil每次评估都是真的.
我有一个我要过滤的swift数组,这里是数组
let array = [apple,workshops,shopping,sports,parties,pantry,pen]
Run Code Online (Sandbox Code Playgroud)
我想过滤数组,使得以搜索字符串开头的项目出现在仅包含搜索字符串的项目之前
因此,当我搜索示例p时,结果应该是某种方式
let array = [parties,pantry,pen,apple,workshops,shopping,sports]
Run Code Online (Sandbox Code Playgroud)
我试过这个
tagSearchResults = tagSearchResults.filter({ (interestTag:InterestTag) -> Bool in
let tmp: NSString = interestTag.tag
let range = tmp.rangeOfString(searchText, options: NSStringCompareOptions.CaseInsensitiveSearch)
return range.location != NSNotFound
})
Run Code Online (Sandbox Code Playgroud)
但这给了我包含搜索字符串的所有字符串.
那么伙计我怎么能这样做呢