can i send objective-c class?

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

Moderators: Lapo, Bax

easthelper
Posts: 1
Joined: 14 Apr 2012, 20:42

can i send objective-c class?

Postby easthelper » 15 Apr 2012, 08:59

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.
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: can i send objective-c class?

Postby Lapo » 16 Apr 2012, 13:15

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
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X iPhone / iPad / OSX API”

Who is online

Users browsing this forum: No registered users and 15 guests