Re: Looking up a NSString constant at runtime

2010-01-04 Thread Scott Ribe
Ah yes, external symbols in a dynamic library--you do have some chance of looking them up at run time ;-) -- Scott Ribe scott_r...@killerbytes.com http://www.killerbytes.com/ (303) 722-0567 voice ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Re: Looking up a NSString constant at runtime

2010-01-04 Thread Mark Ritchie
On 4/Jan/2010, at 4:24 PM, glenn andreas wrote: > CFBundle has routines for looking up both functions and data by name. It > does require you figure out what framework the symbol comes from (and then > get the corresponding CFBundle), but it is doable. Cool, I didn't know that CFBundle exposed

Re: Looking up a NSString constant at runtime

2010-01-04 Thread glenn andreas
On Jan 4, 2010, at 6:13 PM, Graham Cox wrote: > > On 05/01/2010, at 11:03 AM, David Alter wrote: > >> I can open a library and lookup a function by name using dlsym. These >> constants are EXTERN. It seams there should be away to look these up as >> well. > > Functions are not the same, becaus

Re: Looking up a NSString constant at runtime

2010-01-04 Thread David Duncan
On Jan 4, 2010, at 4:03 PM, David Alter wrote: > I can open a library and lookup a function by name using dlsym. These > constants are EXTERN. It seams there should be away to look these up as > well. You should be able to look up extern variables manually, and you can use CFBundleGetDataPointe

Re: Looking up a NSString constant at runtime

2010-01-04 Thread Graham Cox
On 05/01/2010, at 11:03 AM, David Alter wrote: > I can open a library and lookup a function by name using dlsym. These > constants are EXTERN. It seams there should be away to look these up as > well. Functions are not the same, because a function's name is a necessary part of the runtime. A co

Re: Looking up a NSString constant at runtime

2010-01-04 Thread David Alter
I can open a library and lookup a function by name using dlsym. These constants are EXTERN. It seams there should be away to look these up as well. -dave On Mon, Jan 4, 2010 at 3:39 PM, Scott Ribe wrote: > > What if I'm getting a string passed in that is the name of the constant > and > > I wan

Re: Looking up a NSString constant at runtime

2010-01-04 Thread Scott Ribe
> What if I'm getting a string passed in that is the name of the constant and > I want to return the constants string value. Is there a way to do that? This is C, and just as with variables, the names are not there at runtime. If you really need to do this, you'll have to build your own lookup tab

Re: Looking up a NSString constant at runtime

2010-01-04 Thread Nick Paulson
The constant *is* an NSString; essentially you could do: NSString *constValue = NSDeviceResolution; Though, that may be a little redundant. --Nick Paulson On Jan 4, 2010, at 6:09 PM, David Alter wrote: > This would work for finding out what the name is as well as logging it. > > What if I'm g

Re: Looking up a NSString constant at runtime

2010-01-04 Thread David Alter
This would work for finding out what the name is as well as logging it. What if I'm getting a string passed in that is the name of the constant and I want to return the constants string value. Is there a way to do that? something like... NSString * constValue = [SomeToolToLookupConstants constant

Re: Looking up a NSString constant at runtime

2010-01-04 Thread Scott Ribe
I think you're confused: the constant *is* the string; there is no lookup to perform. You can do anything with it that you would do with any other non-mutable string: log it, setStringValue on a text field in the user interface, setMessageText in an alert, and so on. -- Scott Ribe scott_r...@kill

Re: Looking up a NSString constant at runtime

2010-01-04 Thread Oftenwrong Soong
On Mon, Jan 4, 2010 at 4:56 PM, David Alter wrote: > Is there a way to lookup what and NString constant is at runtime? Have you tried [NSDeviceResolution description] or [NSString stringWithString:NSDeviceResolution] ? Soong ___ Cocoa-d

Re: Looking up a NSString constant at runtime

2010-01-04 Thread Sherm Pendley
On Mon, Jan 4, 2010 at 4:56 PM, David Alter wrote: > Is there a way to lookup what and NString constant is at runtime? Just log it, same as any other string: NSLog(@"%@", NSDeviceResolution); sherm-- -- Cocoa programming in Perl: http://www.camelbones.org _

Looking up a NSString constant at runtime

2010-01-04 Thread David Alter
Is there a way to lookup what and NString constant is at runtime? I want to know what the string is for a given constant. For example I would like to pass in the constant name ( i.e. NSDeviceResolution) and get back the NSString that constant represents. I know in this case that the Constant name a