2016-04-20 79 views

回答

0

我發現了一個辦法做到這一點

func getDeepCopy<T>(object: T) -> T { 

    if (T.self is AnyClass) { 
     // It is an instance of a class 
     return deepCopy(object) 
    } 
    // It is an instance of a struct 
    return object 
} 
0

聲明你的功能像這樣:

func getDeepCopy<T: AnyObject>(object: T) -> T 
相關問題