user1285402
user1285402

Reputation: 163

Could not cast value of type 'Swift._SwiftDeferredNSDictionary<Swift.String, Swift.Double>' (0x11b1b84f8) to 'NSMutableDictionary'

I'm calling a method which is written in Objective C,

-(void)fetchWithDetails:(NSMutableDictionary*)details
                  success:(void (^)(id response))success
                  failure:(void (^)(NSError *error,NSString *userMessage))failure;

In Swift I'm calling the objective C method as :

ULWebServiceStoreUtility.fetch(withDetails: parameters as! NSMutableDictionary , success: { (response) in ....}, failure: { error, userMessage in ...})

But I'm getting crash error : Could not cast value of type 'Swift._SwiftDeferredNSDictionary' (0x11b1b84f8) to 'NSMutableDictionary'

So could somebody guide me how to pass NSMutableDictionary in Swift?

Upvotes: 1

Views: 216

Answers (1)

Sulthan
Sulthan

Reputation: 130210

NSDictionary is not directly castable to NSMutableDictionary. The types are different.

You probably need something like this:

fetch(withDetails: NSMutableDictionary(dictionary: parameters), ...)

Upvotes: 1

Related Questions