In Swift, how do you check if an object (AnyObject) is a String? -
tried using:
obj.iskindofclass(string) but says type 'string' not conform protocol 'anyobject'
so how can tell if object string or not?
the context of question uiactivity method, preparewithactivityitems, in need save activity item, if there multiple activity items, how figure out which?
check:
obj string // true or false convert:
obj as? string // nil if failed convert optional binding:
if allow str = obj as? string { // success } else { // fail } string swift
No comments:
Post a Comment