Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Chú thích objectCName
Bạn có thể chú thích bất kỳ phương thức Java nào bằng
@ObjectiveCName để thay đổi tên đã dịch của
phương thức đó và bất kỳ phương thức nào ghi đè phương thức đó. Ví dụ:
@ObjectiveCName("setTimeWithHours:minutes:seconds:")
public void setTime(int hours, int minutes, int seconds) {
...
}
Bạn có thể thay đổi tên phương thức bằng cờ --mapping. Cờ này sẽ lấy một tệp thuộc tính có
ánh xạ cần sử dụng. Mỗi ánh xạ phương thức được xác định bằng chữ ký phương thức Java đầy đủ cho khoá, và
một giá trị bộ chọn Target-C. Ví dụ: dòng để ánh xạ Object.equals() đến NSObject.isEqual:
là:
Phần khai báo bên trái là chữ ký đầy đủ của phương thức, như được Máy ảo Java xác định
Thông số kỹ thuật. Bên phải
tay bao gồm bộ chọn iOS (tức là nội dung bạn sẽ truyền đến @selector()).
Phương thức và ánh xạ của phương thức phải có cùng số lượng tham số.
Một ví dụ khác, dòng này tương đương với ví dụ trong phần trước:
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 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"]]