Skip to content
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

kCRToastTimeIntervalKey issue with Xcode 8.1 swift 3 #213

Open
rogomantik opened this issue Nov 1, 2016 · 4 comments
Open

kCRToastTimeIntervalKey issue with Xcode 8.1 swift 3 #213

rogomantik opened this issue Nov 1, 2016 · 4 comments

Comments

@rogomantik
Copy link

I have this error in the log
[CRToast] : ERROR given 0.4 for key kCRToastTimeIntervalKey was expecting Class __NSCFNumber but got Class _SwiftTypePreservingNSNumber, passing default on instead

@rogomantik
Copy link
Author

also
ERROR given 1 for key kCRToastTextAlignmentKey was expecting Class __NSCFNumber but got Class _SwiftTypePreservingNSNumber, passing default on instead

fixed by setting

kCRToastTimeIntervalKey                 : NSNumber(value: 0.4),
kCRToastTextAlignmentKey                : NSNumber(value: NSTextAlignment.center.rawValue),

but when appear the notification the whole ui flashes

@wsb9
Copy link

wsb9 commented Dec 30, 2016

Noticed same error in log, but proposed fix was not worked for me.

Actually, problem exists because ObjC and Swift internally use different private subclasses of NSNumber class cluster. Proper solution would be opening CRToastConfig.m and changing kCRToastKeyClassMap initialization: instead of extracting classes from default values, which are actually private subclasses of NSNumber, use NSNumber itself. This way, class comparison is done in right way and these warnings disappear.

@Art-Cube
Copy link

Fixed for me by altering the line as such:

    } else if (![obj isKindOfClass:NSClassFromString(kCRToastKeyClassMap[key])] && ![NSStringFromClass([obj class]) containsString:@"Number"]) {

@mohammadshalhoob
Copy link

i fix it like this :

    let options = [kCRToastTextKey:"Hello World!",kCRToastTextAlignmentKey:NSNumber(value: NSTextAlignment.center.rawValue),kCRToastBackgroundColorKey:UIColor.black,kCRToastAnimationInTypeKey:NSNumber(value:CRToastAnimationType.gravity.rawValue),kCRToastAnimationOutTypeKey:NSNumber(value:CRToastAnimationType.gravity.rawValue),kCRToastAnimationInDirectionKey:NSNumber(value:CRToastAnimationDirection.left.rawValue),kCRToastAnimationOutDirectionKey:NSNumber(value:CRToastAnimationDirection.right.rawValue),kCRToastTimeIntervalKey:NSNumber(value:10.0)] as [String : Any]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants