美文网首页
sizeof()&sizeofValue()

sizeof()&sizeofValue()

作者: hauteschwarz | 来源:发表于2016-04-20 12:06 被阅读14次

func sizeof(_: T.Type)

Returns the contiguous memory footprint of T.Does not include any dynamically-allocated or "remote" storage. In particular, sizeof(X.self), when X is a class type, is the same regardless of how many stored properties X has.

Declaration

func sizeof(_: T.Type) -> Int

You can refer to http://swiftdoc.org/v3.0/func/sizeof/#func-sizeof-t_-t-type



import Foundation

class A{

let name: float_t

let a = 4

init(name: float_t){

self.name = name

print("sdfdfs")

}

deinit{

print("sdsf")

}

}

var a = A(name: 234.45)

print(sizeof(A)) //8

let b = [2,3,4]

print(sizeofValue(b)) //8

print(sizeofValue(A)) //8

print(sizeofValue(a)) //8

相关文章

网友评论

      本文标题:sizeof()&sizeofValue()

      本文链接:https://www.haomeiwen.com/subject/albzlttx.html