Re: NSDictionary error
Re: NSDictionary error
- Subject: Re: NSDictionary error
- From: Alan Hart <email@hidden>
- Date: Fri, 14 Apr 2006 13:10:23 +0100
On 13 Apr 2006, at 20:07, Jerrod Fowkes wrote:
Hi, I have been pounding away at this for awhile. I am fairly a
newbie so bare with me:
NSString* value;
value = [[NSString alloc] initWithString: [result objectForKey:
(NSString*) kWSMethodInvocationResult]];
and I am getting this error:
-[NSCFDictionart length]:selector not recognized
[result objectForKey* returns a NSCFDictionary...which I am
assuming to be a pointer to a NSDictionary Object. Well I would
think that initWithString would be able to take that address and
then copy the correct data out of the dictionary for the key
kWSMethod*. What am I doing wrong here?
From your description, the variable result appears to be a reference
to an NSDictionary containing a reference to another NSDictionary at
the key kWSMethodInvocationResult?
-initWithString: can only take an NSString* as its parameter. It's
trying to use the NSDictionary* returned by [result
objectForKey:kWSMethodInvocationResult] as if it were a NSString*,
and it's calling -length on it, and failing.
If [result objectForKey:kWSMethodInvocationResult] returns another
NSDictionary, then you can't pretend it's an NSString. You have to
extract the string you want from it using -objectForKey: with an
appropriate key for that dictionary.
BTW: Assuming result is an NSDictionary*, with
kWSMethodInvocationResult as a valid key, you don't need to cast
kWSMethodInvocationResult to an NSString*.
Alan
_______________________________________________
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