Ich bin neu in Obj-c und ich versuche, ein Cordova-Plugin für die Square Connect-Bibliothek zu erstellen.Fehler beim Aufrufen der Klassenmethode in obj-c
Ich versuche, eine Instanz der Klasse SCCAPIRequest zu erstellen. aber ich erhalte eine Fehlermeldung:
error: no known class method for selector
'requestWithCallbackURL:amount:locationID:notes:metadata:supportedTenderTypes:error:'
Hier ist meine Funktion
- (void)requestCharge: (CDVInvokedUrlCommand *)command {
int amount = [[command.arguments objectAtIndex: 0] intValue];
NSDictionary* options = [command.arguments objectAtIndex: 1];
CDVPluginResult *pluginResult;
if(amount < 0 || amount == 0) {
NSLog(@"Error: Ammount to charge is 0");
NSString *errorResponse = @"Error: Ammount to charge is 0";
pluginResult = [CDVPluginResult
resultWithStatus:CDVCommandStatus_ERROR messageAsString:errorResponse];
}
[self setOptions:options];
NSError *error = nil;
SCCAPIRequest *request = [SCCAPIRequest requestWithCallbackURL:[NSURL
URLWithString:yourCallbackURLString]
amount:amount
locationID:self.locationID
notes:self.note
metadata:self.metadata
supportedTenderTypes:self.tenders
error:&error];
NSData *response = [NSKeyedArchiver archivedDataWithRootObject:request];
if(error) {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
messageAsArrayBuffer:response];
} else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsArrayBuffer:response];
}
[self.commandDelegate sendPluginResult:pluginResult
callbackId:command.callbackId];
}
Vielen Dank im Voraus ist!
Können Sie mich auf ein Tutorial zur Verwendung von 'init' Methoden verweisen? Wie ich schon sagte, ich bin neu in Obj-c. –
Hi @DanielCuesta, die oben angegebenen Codes sind die Funktionen, die Sie aufrufen würden, wenn Sie eine neue Instanz von 'SCCAPIRequest' erstellen. Sie nennen es einfach wie das, was Sie oben getan haben: 'SCCAPIRequest * request = [SCCAPIRequest ...... lalala]' – Glenn
Ich konnte kompilieren, aber ich bekomme einen Fehler 'SCCAPIRequest encodeWithCoder:]: unerkannter Selektor an Instanz gesendet ' –