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 Tutorials > Tutorial Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 12-20-2008, 05:04 AM   #1 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 11
Bollywood is on a distinguished road
Default Reflection Tutorial

I would love to see a reflection tutorial, if someone skilled enough can make one, and upload it.

It is a very necessary coding skill to have, but well above my current coding skill level.

Any takers....

thanks in advance
Bollywood is offline   Reply With Quote
Old 12-20-2008, 07:35 AM   #2 (permalink)
monotreme
 
Join Date: Oct 2008
Location: UK
Posts: 150
spinyanteater is on a distinguished road
Default

I don't know if this is the sort of thing you are looking for, but have you seen the Apple sample code Reflection?
spinyanteater is offline   Reply With Quote
Old 12-21-2008, 03:34 AM   #3 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

You want computer-sciencey-type reflection, not visual effect?

If all you need are to get member variables from a class based on a string, you can take advantage of "KVC" - key value coding. If your object has a property called "xValue" , you can get its value like so:

NSString *keyName = @"xValue";
NSValue *theVal = [myObject valueForKey: keyName];

More info here:
Key-Value Coding Programming Guide: Introduction to Key-Value Coding Programming Guide

If you need to call a method, you can get a selector from the name,
and then call that selector.
SEL aSelector;
aSelector = NSSelectorFromString(@"myMethod:");
[myObject performSelector: aSelector];

More info here:
The Objective-C 2.0 Programming Language: Varying the Message at Runtime

Lastly, to init a class from the name, there's a "classNamed:" method in NSBundle.

http://developer.apple.com/documenta...00214-BCIDHBJF
__________________

Free Games!

Last edited by smasher; 12-21-2008 at 05:11 PM. Reason: add classNamed:
smasher 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
» Stats
Members: 175,696
Threads: 94,139
Posts: 402,961
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jasper_muc
Powered by vBadvanced CMPS v3.1.0

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