CCMutableArray and CCDictionary in lua

I’m having some trouble using a CCMutableArray containing dictionaries in lua.

I have a function in c*+ that returns a CCMutableArray<CCStringToStringDictionary*>* it looks something like this
CCMutableArray<CCStringToStringDictionary*>* getMyArray()
In my lua code if I use that function I get back an object but none of the CCMutableArray functions work, I always get an error that the function is nil. The count call shown here does not work.
@
local theArray = getMyArray
local count = theArray:count
@

I can kind of get something working by doing it a weird way. The count call will work here.
@
local theArray = getMyArray
local convertArray = cocos2d.CCMutableArray_CCObject*:new
convertArray:addObjectsFromArray
print)
@

But now if I take out an object from the array it won’t work as a dictionary
@
local theArray = getMyArray
local convertArray = cocos2d.CCMutableArray_CCObject*:new
convertArray:addObjectsFromArray
local dict = convertArray:getObjectAtIndex
dict:objectForKey
@
That has an error saying that objectForKey doesn’t exist. I know that I have dictionaries in my array since they are built in c*+ and I can access them normally in c++ because I can cast the object.

How about cast the return value to correct type in lua?
Such as
local theArray = (cocos2d.CCMutableArray_CCObject__)getMyArray()