Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-21-2010, 03:02 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 23
wanner is on a distinguished road
Default Possible to list all variables in class?

The background to my problem is: My app is calling a SOAP webservice and retrieving different responses depending on which method is called. Depending on the answer I would like to parse the response into objectA or objectB. To make the parsing of the response as simple as possible I would like to be able to get all fields of a certain class and then create an instance of that class and set the variables.

Example: Lets say i have a class Person with variables name. If the soap response has a tag <name>Bob</name> I would like to be able to set the name field in class Person.

This is possible in java/android with the following code.

Code:
// get fields of class
Class<? extends Object> theClass = myClass.getClass();
Field[] fields = theClass.getDeclaredFields();

// Set value for a specific field
fields[i].set(myClass, strValue);
String tag = fields[i].getName()
One way I thought was to make a general set method for my objects set(field, value). And use that in order to set the specific field. But I would like to use a native method if possible.

Hope someone can help me with this.

Thanks
wanner is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 345
14 members and 331 guests
2ndSegment, cgokey, djohnson, Domele, Hamad, linkmx, markuschow, mistergreen2011, Objective Zero, pungs, revg, Sloshmonster, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:04 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0