Frage

Ich möchte eine iCloud verwenden, aber wenn ich die App unter iOS 4.3 Simulator kompiliere, stürzt sie ab.

dyld: Symbol nicht gefunden: _OBJC_CLASS _ $ _ NSMetadataQuery

Was soll ich tun, damit es unter iOS 3, 4 und 5 funktioniert?

War es hilfreich?

Lösung

Diese API wurde mit dem ios5 gestartet, sodass Sie sie nicht auf dem Simulator 4 oder niedriger ausführen können. Zum Posten können Sie jedoch das Mindestbereitstellungsziel der ios-Familie festlegen, das unterstützt werden soll.

Andere Tipps

meine sulotion ist:

Wo hat sich NSMetadataQuery in id geändert: ex

normal: - (void) loadData: (NSMetadataQuery *) Abfrage; Ändern Sie zu: - (void) loadData: (id) query;

normal: @property (beibehalten, nichtatomar) NSMetadataQuery * -Abfrage; Ändern Sie zu: @property (beibehalten, nichtatomar) ID-Abfrage;

und überprüfen Sie die verfügbare iCloud:

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

Bei Verwendung von NSMetadataQuery:

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

Viel Spaß (^_^)

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
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top