Swift + macro parameters

后端 未结 3 1089
时光取名叫无心
时光取名叫无心 2021-01-06 19:42

I read all Q&A related to Macros in Swift, And i did figure out that everything in Swift now global, Am i right?

3条回答
  •  抹茶落季
    2021-01-06 20:15

    You will probably need to convert it into a function or generic, as per this documentation page:

    "Complex macros are used in C and Objective-C but have no counterpart in Swift. Complex macros are macros that do not define constants, including parenthesized, function-like macros. You use complex macros in C and Objective-C to avoid type-checking constraints or to avoid retyping large amounts of boilerplate code. However, macros can make debugging and refactoring difficult. In Swift, you can use functions and generics to achieve the same results without any compromises. Therefore, the complex macros that are in C and Objective-C source files are not made available to your Swift code."

提交回复
热议问题