I have following problem: I have ObjC protocol with swift implementation:
// ObjC protocol
@protocol PhonebookSomeEventCallback
- (void)onEvent:(nonnull NSUUID *)outUserId
someNumValue:(int32_t)someNumValue
lotOfPersons:(nonnull NSArray<PhonebookPerson *> *)lotOfPersons;
@end
//=====================================
// Swift impl
class PhonebookSomeEventCallbackImpl: PhonebookSomeEventCallback
{
public func onEvent(_ outUserId: UUID,someNumValue: Int32,lotOfPersons: [PhonebookPerson])
{
}
}
And it fails to build with following error:
error: instance method 'onEvent(_:someNumValue:lotOfPersons:)' has different argument labels from those required by protocol 'PhonebookSomeEventCallback' ('onEvent(_:someNumValue:lotOf:)')
public func onEvent(_ outUserId: UUID,someNumValue: Int32,lotOfPersons: [PhonebookPerson])
^
lotOf
Phonebook.PhonebookSomeEventCallback:3:10: note: requirement 'onEvent(_:someNumValue:lotOf:)' declared here
func onEvent(_ outUserId: UUID, someNumValue: Int32, lotOf lotOfPersons: [PhonebookPerson])
^
/Users/g.a.igumnov/work/mobile/phonebook/controller/mobile-app/x86_64/subprojects/controller/service-sbis-phonebook/phonebook/djinni/swift/phonebook/PhonebookSomeEventEvent.swift:32:17: error: 'onEvent(_:someNumValue:lotOfPersons:)' has been renamed to 'onEvent(_:someNumValue:lotOf:)'
public func onEvent(_ outUserId: UUID,someNumValue: Int32,lotOfPersons: [PhonebookPerson])
^
lotOf
Phonebook.PhonebookSomeEventCallback:5:10: note: 'onEvent(_:someNumValue:lotOfPersons:)' was obsoleted in Swift 3
func onEvent(_ outUserId: UUID, someNumValue: Int32, lotOfPersons: [PhonebookPerson])
Experimentally I found following principles If arguments name ends with one of keywords ('of', 'with', 'by', 'from', 'on' - those I've found) followed by type name (or part of it, I have class PhonebookPerson, but just Person works) in plural for arrays and singular for non-arrays, type name is removed from argument name.
I have two questions
- Is there any documentation on this black magic?
- What is the proper way to avoid it except for not writing such names?