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 02-21-2009, 03:01 PM   #1 (permalink)
New Member
 
Join Date: Feb 2009
Posts: 49
Joche is on a distinguished road
Default How to retrieve a property from a class using a variable as the name?

This is more a C question than an iPhone question I guess. I have a class with a bunch of properties, they are all either @synthezised or have proper setters/getters.

Now I need to retrieve that value in them by using a dynamic name.
I just can't figure out how to do it.

Pseudocode:

MyClass{

NSString *firstName;
NSString *lastName;

}

CallerClass {
MyClass myClass = [MyClass alloc];
NSString propertyName = @"firstname";

// NEED HELP HERE:
NSString theValue = myClass.getByWhateverTheMethodIsCalled(propertyNam e);


}
Joche is offline   Reply With Quote
Old 02-21-2009, 04:09 PM   #2 (permalink)
New Member
 
Join Date: Sep 2008
Posts: 1,431
PhoneyDeveloper is on a distinguished road
Default

Look at the Key-Value Coding Programming Guide.
PhoneyDeveloper is offline   Reply With Quote
Old 02-21-2009, 04:55 PM   #3 (permalink)
New Member
 
Join Date: Feb 2009
Posts: 49
Joche is on a distinguished road
Default

Quote:
Originally Posted by PhoneyDeveloper View Post
Look at the Key-Value Coding Programming Guide.
Thanks alot for that tip! Very useful stuff.

For other viewers, here's the link to the Key-Value Coding Programming Guide:
Joche 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: 330
4 members and 326 guests
guusleijsten, HowEver, LEARN2MAKE, mottdog
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,880
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

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