Finding the type of a value in an SFSObject?

Post here your questions about the Objective-C API for SFS2X

Moderators: Lapo, Bax

AB
Posts: 4
Joined: 19 Jan 2011, 19:08

Finding the type of a value in an SFSObject?

Postby AB » 24 Feb 2011, 18:59

Is there a way to find out the type of a value contained inside a SFSObject of which only the key is known? Or a way to retrieve an object by its key, but without prior knowledge of the type?

The reason I'm looking for this is that we want to collect all values contained in a SFSObject together and make a string of it... We want that string to be the same on the server( java) as well as on the client( iphone or c# ).

I've seen methods such as
-(SFSDataWrapper *)getData:(NSString *)key;
and
-(id)getClass:(NSString *)key;

but no documentation mentions them. I'm worried this is for internal use only and can change without a warning.
Our server guy says he uses the method "data" (in java).

So? what about these two methods? Any other way that exists on all sides?

Thanks in advance.
User avatar
cemuzunlar
Posts: 47
Joined: 26 Dec 2008, 00:45
Contact:

Postby cemuzunlar » 26 Feb 2011, 15:03

You can get a list of keys contained in the SFSObject by using:

-(NSArray *)getKeys;

method.

Then, iterate over the returned array and use:

-(SFSDataWrapper *)getData:(NSString *)key;

method to get the data associated the the key.

The returned SFSDataWrapper has a type property. You can compare this with the types in the SFSDataType.h file to get the type.

Then according to the type, you can either cast the data property in the SFSDataWrapper, or use the appropriate function in the SFSObject to get your value as correctly typed.
Cem Uzunlar
Infosfer Game and Visualization Technologies
http://www.infosfer.com
contact@infosfer.com

Return to “SFS2X iPhone / iPad / OSX API”

Who is online

Users browsing this forum: No registered users and 1 guest