在iOS 4上编译时iphone iCloud应用程序崩溃

Bar*_*cki 1 iphone compiler-errors icloud

我想使用iCloud,但是当我在iOS 4.3模拟器上编译应用程序时它会崩溃.

dyld:未找到符号:_OBJC_CLASS _ $ _ NSMetadataQuery

我该怎么做才能让它在iOS 3,4和5上运行?

小智 6

我的闷闷不乐是:

NSMetadataQuery在哪里更改为id:ex

normal: - (void)loadData:(NSMetadataQuery*)query; 更改为: - (void)loadData:(id)query;

normal:@property(retain,nonatomic)NSMetadataQuery*query; 更改为:@property(保留,非原子)id查询;

并检查iCloud可用:

if ([[NSFileManager defaultManager] respondsToSelector:@selector(URLForUbiquityContainerIdentifier:)]) {
        NSURL *ubiq = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
        if (ubiq) {
            // Code for access iCloud here
        }
    }
Run Code Online (Sandbox Code Playgroud)

使用NSMetadataQuery时:

id _query = [[NSClassFromString(@"NSMetadataQuery") alloc] init];
// Some code here
[_query startQuery];
Run Code Online (Sandbox Code Playgroud)

玩得开心(^_^)