ios - Type of Generic -


can somehow check type of t. want check type array or else.

func request<t: mappable>(completionhandler: (result<t>) -> void) {  } 

one way overload method, so:

private func request<t: mappable>(isarray: bool, completionhandler: (result<t>) -> void) {   if isarray {     print("is array")   } else {     print("is not array")   } }  func request<t>(completionhandler: (result<array<t>>) -> void) {   request(isarray: true, completionhandler: completionhandler) }  func request<t: mappable>(completionhandler: (result<t>) -> void) {   request(isarray: false, completionhandler: completionhandler) } 

i'm assuming somewhere have defined:

extension array: mappable {} 

Comments

Popular posts from this blog

sql - can we replace full join with union of left and right join? why not? -

javascript - Parallax scrolling and fixed footer code causing width issues -

iOS: Performance of reloading UIImage(name:...) -