• 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
Using an NSString to refer to a variable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using an NSString to refer to a variable


  • Subject: Using an NSString to refer to a variable
  • From: René Lepage <email@hidden>
  • Date: Wed, 5 Nov 2003 17:16:12 -0500

Hello there.

Is there a way to enforce a NSString that refers to the name of a constant to return a string?

I work within the AddressBook Framework and I want to set an ABPerson value. I use :

[aPerson setValue:aValue forProperty:aProperty];

where "aValue" is a NSString and "aProperty" is another NSString (that comes from an array) set to "kABFirstNameProperty", for instance. It doesn't work. It works only if I write explicitly a valid property like this :

[aPerson setValue:aValue forProperty: kABFirstNameProperty]

I doubt it is possible since it depends on the implementation of setValue. What puzzles me is that if I NSlog(@"%@", aProperty), I get "kABFirstNameProperty" while if I use it within setValue, I get an error message like :

*** Assertion failure in -[ABPerson nts_SetValue:forProperty:], Framework/AddressBook/ABRecord.m:386
Unknown property 'Michhle' type '-1608948992

Any suggestion or comment someone? It would be appreciate.

Reni Lepage
Quibec
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Using an NSString to refer to a variable
      • From: Fritz Anderson <email@hidden>
  • Prev by Date: Fix and Continue broken?
  • Next by Date: Re: Freelance programming
  • Previous by thread: Fix and Continue broken?
  • Next by thread: Re: Using an NSString to refer to a variable
  • Index(es):
    • Date
    • Thread