ios - How to check if an id points to a CGRect? -
supposing have:
id value = [self valueforkey:@"frame"]; bool valueiscgrect = ???; how can decide? should cast id something?
the returned value of type nsvalue scalar types, provides method objctype, returns encoded type of wrapped scalar type. can use @encode() encoding arbitrary type, , compare objctype.
if(strcmp([value objctype], @encode(cgrect)) == 0) { // it's cgrect }
Comments
Post a Comment