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

Re: Using an NSString to refer to a variable


  • Subject: Re: Using an NSString to refer to a variable
  • From: Fritz Anderson <email@hidden>
  • Date: Thu, 6 Nov 2003 09:19:55 -0600

On 5 Nov 2003, at 4:16 PM, Reni Lepage wrote:

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]

kABFirstNameProperty is the name of an NSString pointer constant. There is no reason to assume that the string to which it refers is "kABFirstNameProperty". If you want an NSArray with that property name in it, you should NOT do:
[NSArray arrayWithObject: @"kABFirstNameProperty"]
you SHOULD instead do:
[NSArray arrayWithObject: 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.

If the problem persists, you should post the source code. A stranger's eyes can be a powerful debugger.

-- F
_______________________________________________
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.

References: 
 >Using an NSString to refer to a variable (From: René Lepage <email@hidden>)

  • Prev by Date: Re: Unclear on NSView's isOpaque concept (and optimization in general)
  • Next by Date: Xcode suddenly forgets CVS
  • Previous by thread: Using an NSString to refer to a variable
  • Next by thread: Re: Newbie NSTableView question
  • Index(es):
    • Date
    • Thread