iphone iCloud app crashes when compiling on iOS 4

前端 未结 3 1621
梦毁少年i
梦毁少年i 2021-01-27 05:05

I\'d like to use an iCloud, but when I compile the app on iOS 4.3 Simulator it crashes.

dyld: Symbol not found: _OBJC_CLASS_$_NSMetadataQuery

What should I do to

相关标签:
3条回答
  • 2021-01-27 05:30

    The usual way would be to compile it with iOS 5 SDK and setting the deployment target to the oldest iOS Version you'd like it to work with. It's up to you though to check at runtime on which classes and methods are available to the current system. A user on iOS 4 for example will not be able to use functions that only ship with iOS 5.

    To check the availability of classes do:

    if ( NSClassFromString(@"NSMetadataQuery") != nil ) {
      //do stuff with NSMetadataQuery here
    }
    

    To check the availability of methods do:

    if ( [myObject respondsToSelector:@selector(doSomething)] ) {
      //call doSomething on myObject
    }
    
    0 讨论(0)
  • 2021-01-27 05:32

    These API has been launched with the ios5 so you cann't run it on the simulator 4 or below but for posting you can set the minimum deployment target of ios family it should support .

    0 讨论(0)
  • 2021-01-27 05:52

    my sulotion is:

    Where have NSMetadataQuery change to id: ex

    normal : - (void)loadData:(NSMetadataQuery *)query; change to: - (void)loadData:(id)query;

    normal: @property (retain, nonatomic) NSMetadataQuery *query; change to: @property (retain, nonatomic) id query;

    and check iCloud available:

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

    When use NSMetadataQuery:

    id _query = [[NSClassFromString(@"NSMetadataQuery") alloc] init];
    // Some code here
    [_query startQuery];
    

    Have fun (^_^)

    0 讨论(0)
提交回复
热议问题