Extending • Swift-class component returns nil
See original GitHub issueExtending with custom components doesn’t work for Swift classes.
There is an issue in JasonComponentFactory
in method build:withJSON:withOptions:
:
NSClassFromString(componentClassName)
returns nil for Swift classes, because Swift class name have a different format:
<appName>.<className>
or <appName>_<targetName>.<className>
instead of just <className>
in Obj-C classes.
Therefore component class names must have a prefix for Swift classes, i.e. MyAppName.JasonSuperComponent
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
New stored property always returns nil | iOS Swift
A new stored property created for exisiting class using extension. While getting value its always returning nil value. The below code is what...
Read more >Extensions — The Swift Programming Language (Swift 5.7)
Extensions¶. Extensions add new functionality to an existing class, structure, enumeration, or protocol type. This includes the ability to extend types for ...
Read more >Extending optionals in Swift | Swift by Sundell
Converting nil into errors. When working with optional values, it's very common to want to convert a nil value into a proper Swift...
Read more >Understanding Functional Components vs. Class ... - Twilio
A class component is a JavaScript class that extends React.Component which has a render method. A bit confusing?
Read more >4. Object Types - iOS 8 Programming Fundamentals with Swift ...
Inside a static/class method, self is the type. ... But if nil was returned, any attempt on the caller's part to access members...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
yes,
@objc(MySwiftClass)
works fineTry this in your swift code
https://stackoverflow.com/a/30895110
All swift classes use the Product Module Name a dot and the classname for their namespace (Module.Class). If you wanted to use “MySwiftClass” name for the class within your Objective-C code; you can add
@objc(MySwiftClass)
annotation to expose the same swift class name (without the module):Then
Will contain the class instead of being nil.