mosaic6
mosaic6

Reputation: 933

Cannot invoke initializer for type 'NSMutableDictionary' with an argument list of type

Cannot invoke initializer for type 'NSMutableDictionary' with an argument list of type '(objectsAndKeys: String, String, String, String, String, String, NSNumber, String, String, String)'

Anyone have thoughts on why I'm getting this error?

data = NSMutableDictionary(objectsAndKeys:
            VPDateFormatter.dateFormatterPost.stringFromDate(NSDate().myGetDateWithDayDifference(dateOffset)), "activityDate",
            tracker.objectForKey(VPTracker_Description) as! String, "activityDescription",
            trackerType, "activityType",
            currentMemberID, "memberid",
            VPDateFormatter.dateFormatterOnlyDate.stringFromDate(date), kVPTrackerStatistic_MemberDate
        )

Upvotes: 1

Views: 940

Answers (2)

keithbhunter
keithbhunter

Reputation: 12334

With swift you can use a var Dictionary<String, AnyObject> instead of NSMutableDictionary.

var data = [
        "activityDate" : VPDateFormatter.dateFormatterPost.stringFromDate(NSDate().myGetDateWithDayDifference(dateOffset)),
        "activityDescription" : tracker.objectForKey(VPTracker_Description) as! String,
        "activityType" : trackerType,
        "memberid" : currentMemberID,
        kVPTrackerStatistic_MemberDate : VPDateFormatter.dateFormatterOnlyDate.stringFromDate(date) 
]

Using this notationg may allow the swift compiler to pinpoint any error you have instead of the long error about method signatures. Also, this will give you type checking!

Upvotes: 0

Greg Price
Greg Price

Reputation: 2556

I am pretty sure swift defines that particular method as

NSMutableDictionary(objects: <#T##[AnyObject]#>, forKeys: <#T##[NSCopying]#>)

So you would have to adjust accordingly. I know it does in 2.0

In fact I would suggest using swift DataTypes I know it can be a pain coming from objective c to get used to but its worth it, I would go with a Dictionary here

Upvotes: 2

Related Questions