ios - Additional readonly properties from keys via category -


in project, getting passed data object (xyzcustomclass) custom sdk. never need modify object, use , present data in ui. custom data object has 5 normal string properties, , nsdictionary type property called "addditionalproperties". dictionary contains set of key value pairs.

what want in client part, have real properties on custom data object match keys. want have nice interface being real property. don't want have stuff hidden under keys, while other accessible normally.

i want create category on data object declare 1) public readonly properties each key 2) implement getters retrieve object particular key relevant particular property.

working on 4.6.3 xcode. base sdk 5.0. approach ok? work?

remember, readonly, please no associated object suggestions.

you can dot sugar syntax, if simple declare method on .h file of category so:

@interface customdataobject (additionalproperties)  -(nsstring *)amount;  @end 

you can:

nslog(@"%@", myobject.amount); 

if don't want declare method every element might inside dictionary can like:

@interface customdataobject (additionalproperties)  -(nsstring *)additionalpropertieskey:(nsstring *)key;  @end 

but lose dot syntax, because in case method expects parameter.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -