foreach on SFSObject
foreach on SFSObject
Which is the proper way to make a "foreach" loop on a SFSObject?
Re: foreach on SFSObject
SFSObject means SmartFoxServer 2X, so this is the wrong section I'll move the topic.
A for each is kind of a complicated thing to do because you don't know which type of object and key you're expecting.
It can be done but you should probably describe more clearly what you're trying to do.
thanks
A for each is kind of a complicated thing to do because you don't know which type of object and key you're expecting.
It can be done but you should probably describe more clearly what you're trying to do.
thanks
Re: foreach on SFSObject
Ok, thanks.
I put it on the server forum because we wanted it to do on the server (on Java), but it's clear.
I'll try to make without the foreach loop.
I put it on the server forum because we wanted it to do on the server (on Java), but it's clear.
I'll try to make without the foreach loop.
Re: foreach on SFSObject
If you're expecting a number of items try using an array instead.
For example if you're sending a bunch of strings send a String array via SFSObj.putUtfStringArray(key, value);
If the type of these objects is not known, then you can use an SFSArray which accepts any types (among those supported).
You can then cycle on it like this:
which will allow you to detect the type of each item in the array.
cheers
For example if you're sending a bunch of strings send a String array via SFSObj.putUtfStringArray(key, value);
If the type of these objects is not known, then you can use an SFSArray which accepts any types (among those supported).
You can then cycle on it like this:
Code: Select all
for (int i =0; i < sfsArray.size(); i++)
{
SFSDataWrapper item = sfsArray.get(i);
if (item.getTypeId() == SFSDataType.DOUBLE)
...
...
}
which will allow you to detect the type of each item in the array.
cheers
Who is online
Users browsing this forum: Baidu [Spider] and 96 guests