-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DIA-4058 refactor ios interface #63
DIA-4058 refactor ios interface #63
Conversation
switch CAMPAIGN_TYPE(rawValue: campaignType) { | ||
case .GDPR: consentManager!.loadGDPRPrivacyManager(withId: pmId, tab: tab) | ||
case .CCPA: consentManager!.loadCCPAPrivacyManager(withId: pmId, tab: tab) | ||
case .USNAT: consentManager!.loadUSNatPrivacyManager(withId: pmId, tab: tab) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
were you can use:
guard let consentManager = consentManager else {
self.callbacks.RunCallback(callbackType: .OnErrorCallback, arg: "Library was not initialized correctly!")
return
}
// from here on we don't need to force unwrap consentManager(!) since the guard let took care of it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, could we think about a way of making consentManager
not optional? This way we don't have to keep checking if it's nil on every method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andresilveirah having guard
is a good idea, thanks!
As for making consentManager
not optional – for now I cannot imagine how to do it, because to make it not optional we have to initialize it with values, and we cannot declare and initialize them in one place since we wait for the initialization-related data to come from Unity side of a bridge.
I have to think a little bit about it.
callback: @escaping Callbacks.СallbackCharMessage = printChar, | ||
callbackType: Callbacks.CallbackType = .NotSet) { | ||
self.callback = callback | ||
self.callbackType = callbackType | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like what you did with the Callbacks
class 👏 .
// foreach (var kvp in TCData) | ||
// sb.AppendLine($" {kvp.Key}: {kvp.Value}"); | ||
foreach (var kvp in TCData) | ||
sb.AppendLine($" {kvp.Key}: {kvp.Value.ToString()}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have to call Value.ToString()
? Some values inside TCData
may not be a string (sometimes they have booleans like 0 or 1).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andresilveirah .ToString()
in c# can handle value types just right.
For example, it will convert a boolean value to string True
or False
and a 1
integer will become "1" string.
We can decide not to specify .ToString()
here but it will be done anyway under the hood.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TCData.Value
has an object
type, which means it can be any value-type value that secures the usage of .ToString()
No description provided.