swift - Cannot invoke 'sizeof' with an argument list of type '([Double])' -
i got error message when invoke sizeof
.
/users/mnurdin/documents/ios/xxxxx/viewcontroller.swift:46:58: cannot invoke 'sizeof' argument list of type '([double])'
my code
let wts: [double] = [ -30 , 20 , 20 ] let weights: nsdata = nsdata(bytes: wts, length: sizeof(wts))
what doing wrong?
don't use sizeof()
on instance, expects type. use sizeofvalue()
instead.
let wts: [double] = [-30, 20, 20] let weights = nsdata(bytes: wts, length: sizeofvalue(wts) * wts.count)
note need multiply sizeofvalue's value count of array, since return size of each element in array , not size of entire array.
Comments
Post a Comment