Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Annotazione ObjectiveCName
Puoi annotare qualsiasi metodo Java con
@ObjectiveCName per modificare il nome tradotto di
quel metodo e qualsiasi metodo che lo sostituisca. Ad esempio:
@ObjectiveCName("setTimeWithHours:minutes:seconds:")
public void setTime(int hours, int minutes, int seconds) {
...
}
I nomi dei metodi possono essere modificati utilizzando il flag --mapping, che accetta un file delle proprietà con la proprietà
mapping da usare. Ogni mappatura dei metodi viene definita con la firma completa del metodo Java per la chiave e
un valore del selettore Objective-C. Ad esempio, la riga per mappare Object.equals() a NSObject.isEqual:
è:
La dichiarazione di sinistra è la firma completa del metodo, come definita dalla Java Virtual Machine
Specifiche. A destra
la definizione della mano è composta dal selettore iOS (ossia ciò che passeresti a @selector()).
Il metodo e la relativa mappatura devono avere lo stesso numero di parametri.
Come ulteriore esempio, questa riga è equivalente all'esempio della sezione precedente:
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2024-08-28 UTC."],[[["The `@ObjectiveCName` annotation allows developers to rename Java methods and their overrides within the translated Objective-C code."],["Method renaming can also be accomplished using mapping files specified with the `--mapping` flag during translation, providing an alternative to annotations."],["Mapping files utilize a key-value structure where the key is the Java method signature and the value is the desired Objective-C selector, ensuring both have the same parameter count."]]],["The `@ObjectiveCName` annotation renames Java methods in their Objective-C translation. The annotation's string value defines the desired Objective-C selector, excluding parameter types and names. Alternatively, the `--mapping` flag utilizes a properties file to map Java method signatures to Objective-C selectors. Each mapping specifies the full Java method signature on the left and the Objective-C selector on the right. Multiple mapping files can be provided. Mapped methods must have the same number of parameters.\n"]]