English 中文(简体)
i : 如何在用户制作的名录中读
原标题:iCloud: How to read in directories created by the user

我想读到一份由用户或i± 移动文件目录中用户创建的所有名录清单(见Lion中“~/Library/Mobile Documents”下的目录)。 下面是该名录如何看待:

“iux

我尝试了以下法规,但问询表一将不包含代表我方的物体(使用国家清单<代码>predicateWithFormat:@%K.pathExtension=“,NSMetadataItemFSNameKey)。 如果我对txt案卷(使用@>%K ENDSWITH .txt”、NSMetadataItemFSNameKey)提出质询,我将分别收到5个 objects。 因此,查阅txt文档是行之有效的,但不是用于名录。 通过 我注意到, Apple果建议使用NSFileWrapper(碎片包)而不是名录。 i±是否能够处理用户或用户创建的影子?

我的守则是:

-(void)loadDocument {

    NSMetadataQuery *query = [[NSMetadataQuery alloc] init];
    _query = query;
    //Search all files in the Documents directories of the application’s iCloud container directories:
    [query setSearchScopes:[NSArray arrayWithObject:NSMetadataQueryUbiquitousDocumentsScope]]; 

    NSPredicate *pred = [NSPredicate predicateWithFormat:@"%K.pathExtension =   ", NSMetadataItemFSNameKey];

    [query setPredicate:pred];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryDidFinishGathering:) name:NSMetadataQueryDidFinishGatheringNotification object:query];
    [query startQuery];
}

- (void)queryDidFinishGathering:(NSNotification *)notification {

    NSMetadataQuery *query = [notification object];
    [query disableUpdates]; // You should invoke this method before iterating over query results that could change due to live updates.
    [query stopQuery]; // You would call this function to stop a query that is generating too many results to be useful but still want to access the available results.

    [self loadData:query];

    [[NSNotificationCenter defaultCenter] removeObserver:self name:NSMetadataQueryDidFinishGatheringNotification object:query];
    _query = nil; // we re done with it
}


- (void)loadData:(NSMetadataQuery *)query {

   NSLog(@"Query count %i", [query resultCount]);

    for (int i=0; i < [query resultCount]; i++) {
        NSMetadataItem *item = [query resultAtIndex:i];
        NSURL *url = [item valueForAttribute:NSMetadataItemURLKey];
        NSLog(@"%i.URL: %@", i, url);
    }

}
最佳回答

我在MacOS X狮子的“管理储存”。 当我点击我的申请时,它将只显示不同的txt文档(加上相互冲突的版本)和任何目录。 因此,我不得不假设,你只能与包装材料/档案包合作,而不能与目录合作。

问题回答

暂无回答




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签