• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Evaluating an NSString to a symbol at runtime...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Evaluating an NSString to a symbol at runtime...


  • Subject: Re: Evaluating an NSString to a symbol at runtime...
  • From: Andre <email@hidden>
  • Date: Mon, 18 Sep 2006 21:22:23 -0700


On 2006/09/18, at 17:52, Finlay Dobbie wrote:

On 18/09/06, Mailing list subscriptions <email@hidden> wrote:
El 18/09/2006, a las 22:45, email@hidden escribió:

> I have a situation where I have a string passed into my controller
> where it needs to be evaluated into an extern NSString constant.
> As an example, I get the value @"kABPhoneWorkFAXLabel" passed in.
>
> If I do the following:
>
> NSString *stringFromTextField = [textField stringValue]; //(IOW it
> is @"kABPhoneWorkFAXLabel" )
> ABPerson *person = [self getARandomPerson];
> [person valueForProperty:stringFromTextField];
>
> It will always of course return nil. Is there a method to evaluate
> *stringFromTextField to a named constant?
> Something like constNamed() function that would evaluate the obj-c
> symbol and find it?

man NSModule

Or for a higher level, CFBundle.

-- Finlay
OK, I tried this, but I either get "Invalid" returned or nil...

If I do a symbol lookup in the AddressBook framework, I get the following:

a4cd60f8 s _kABEditPersonNotification
         U _kABEmailHomeLabel
         U _kABEmailProperty
         U _kABEmailWorkLabel
         U _kABFatherLabel
         U _kABFirstNamePhoneticProperty
         U _kABFirstNameProperty
         U _kABFriendLabel
         U _kABGroupClassKey
         U _kABGroupNameProperty

Here is my code, still get nil....

CFStringRef accessKey = (CFStringRef)[@"_" stringByAppendingString: [aTableColumn identifier]]; //(Returns kABEmailWorkLabel)

NSString *targetFramework = @"com.apple.AddressBook.framework";
CFBundleRef ABFramework = CFBundleGetBundleWithIdentifier ((CFStringRef) targetFramework);

NSString *ABNamedConstant = (NSString *)CFBundleGetDataPointerForName (ABFramework,accessKey);


Still returns null, if I leave the underscore out, I get a symbol, but its reads as "invalid"...

Any pointers??
Thanks for all the help!!

Andre



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Evaluating an NSString to a symbol at runtime...
      • From: Chris Suter <email@hidden>
References: 
 >Evaluating an NSString to a symbol at runtime... (From: email@hidden)
 >Re: Evaluating an NSString to a symbol at runtime... (From: Mailing list subscriptions <email@hidden>)
 >Re: Evaluating an NSString to a symbol at runtime... (From: "Finlay Dobbie" <email@hidden>)

  • Prev by Date: stepper motors + OS X
  • Next by Date: Re: Evaluating an NSString to a symbol at runtime...
  • Previous by thread: Re: Evaluating an NSString to a symbol at runtime...
  • Next by thread: Re: Evaluating an NSString to a symbol at runtime...
  • Index(es):
    • Date
    • Thread