Applies to:
- Xcode Extension
- Finder Extension
- Advanced Project Converter
- Offline Converter
Included in plans:
- Cloud
- Offline Converter
Scope
This conversion option currently affects the optionality of the following:
- Method parameters
- Return types
- Properties
- Fields
- Global variables
- Local variables
Overview
With this conversion option, you can now treat pointer-type method parameters, return types, and properties as either:
- Optional (
?
): Swiftify defaults to treating pointer-type parameters and return types as optional. -
Implicitly Unwrapped Optional (
!
): If you check the Swift interface for an Objective-C header file you'll find that Xcode imports Objective-C pointer type parameters and return values as implicitly unwrapped optionals in Swift. -
Non-optional: Selecting this option reduces the number of optional unwrappings in the generated Swift code. If your code is wrapped between
NS_ASSUME_NONNULL_BEGIN
andNS_ASSUME_NONNULL_END
macros or for pointers marked as_Nonnull
ornonnull
the converter output will be similar to the case if Non-optional was selected.
Objective-C code:
Converted Swift code with Optional mode selected:
Converted Swift code with Implicitly Unwrapped Optional mode selected:
Converted Swift code with Non-optional mode selected:
To toggle this feature open Preferences (⌘+,) => Converter and choose from the available options:
Comments
0 comments
Please sign in to leave a comment.