Open tmspzz opened 7 years ago
@otymartin Thanks! However does not seem like this has changed much (looking at 1.0.4
)
/** Optional channel delegate. Upon setting the delegate, you will receive the current channel synchronization status by delegate method. */
weak open var delegate: TCHChannelDelegate!
@blender Im failing to understand your problem with that delegate declaration? weak open car delegate: TCHCHannelDelegate!
?
Since the delegate is weak
it can be nil at any moment. Accessing it by channel.delegate
when this is declared implicitly unwrapped can cause a segmentation fault at any moment (if in fact it happens to be nil).
It is good practice (and much safer) to declare delegates as weak and optional.
weak open var delegate: TCHChannelDelegate?
I am going around this by defining in an extension
extension TCHChannel: ChatChannelWithDelegate {
public weak var optionalDelegate: TCHChannelDelegate? {
guard let delegate = self.delegate else { return nil }
return delegate
}
}
Poking around this gives me very little confidence is the status of the SDK and the abstractions that one can build around it.
@blender Good find, it completely went over my head. @rbeiter
I am guessing it's just a matter of adding proper nullability annotations to the objc sdk. Swift has been around for quite some time now.
If anyone from Twilio reads this please let me know if this is the right forum or if I should be discussing this elsewhere. Thanks.
Hi @blender - I'm on the team taking care of the iOS Chat SDK's. This is indeed related to not having nullability hints in the Obj-C interfaces and addressing this is already in process for 2.x which is coming soon. We'll update this issue when 2.0 is released. Let us know here or through our support portal (https://support.twilio.com/) if we can assist further. Thanks!
@rbeiter Thank you very much. Looking forward to the changes.
@rbeiter TCHMessage timeStampAsDate
is nil for this string 2017-08-17T15:34:30.513Z
Since timeStampAsDate
is Date!
this causes a crash. Twilio chat 1.0.7.
See proper ISO date parsing here: https://github.com/cheeyi/ProjectSora/blob/master/Pods/AFDateHelper/AFDateHelper/AFDateExtension.swift
Hi,
we are currently considering Twilio for a large chat application but the TwilioChatClient Swift interface looks sketchy at best.
Consider these lines from TCHChannel:
Am I looking at production code? Is there a newer version of the SDK I should be looking at? I am Currently on
0.16.1
Is this the right forum where to ask questions?