Page 1 of 1

can i send objective-c class?

Posted: 15 Apr 2012, 08:59
by easthelper
hi.

i'm trying sending model class. android is good.
but ios doesn't work and can't find working example or explanation that in this site.
sfs2x server output 'can't find a class' exception.

i have a few questions.

1. in docs 'http://docs2x.smartfoxserver.com/AdvancedTopics/class-serialization'
Implement the SerializableSFSType interface. This interface has no methods, and it just works as a "marker" for serializable classes.
iOS API SerializableSFSType protocol require method implementation '-(NSMutableDictionary *)dictionary;'
what i implement in this method?

2.
Use the same exact package and class name on boths sides of the application. In other words the RpgCharacter class must reside in the same package both in Java and Actionscript.
Objective-C doesn't have an equivalent to Java packages. Are there other alternatives?

thanks and sorry for bad eng.

Re: can i send objective-c class?

Posted: 16 Apr 2012, 13:15
by Lapo
We don't support this feature in Objective-C.
There are several problems:
1- As you mentioned there's a lack of "packages" in Obj-C which prevents the system to work correctly from the get go.
2- Runtime type reflection is usually resource intensive, especially with limited CPU power such as with the iPhone
3- Serialized classes produce larger packets which end up using more resources and bandwidth, again a possible performance hit for smartphones.

Our recommendation is to add a toSFSObject() and fromSFSObject() methods to each of your classes that require to be sent over the wire. In those methods you can selectively choose which fields to transmit and which datatypes to use.

Hope it helps