Re: Dictionary keys(Solved)
Re: Dictionary keys(Solved)
- Subject: Re: Dictionary keys(Solved)
- From: Hisaoki Nishida <email@hidden>
- Date: Wed, 12 Mar 2003 21:06:09 -0500
Hi,
Thanks for your input.
I thought that NSMutableDictionary would return nil if the key wasn't
found,
so I didn't think the value of NSPoint mattered. But I tried printing
the value as you said,
and it turns out it's not something I expected.
Even if so, I expected the dictionary to return nil if the value wasn't
found.
(i.e. the NSPoint is a coordinate on a board game; if the point doesnt
point to a piece on board,
return nil)
I depend on this, so finding out that it causes an error is rather..
annoying.
Thanks again,
-yuki
On Wednesday, March 12, 2003, at 08:50 PM, sinclair44 wrote:
On 3/12/03 8:26 PM, "Hisaoki Nishida" <email@hidden> wrote:
I get a signal 11 SIGSEGV error when I try to do the following:
[anArray objectForKey:NSStringFromPoint(newPoint)];
anArray is an NSMutableArray, and objects contained in it are stored
with the key NSStringFromPoint(somePoint).
They are both strings, so why wouldn't it work?
Thanks.
(I'm assuming you meant 'aDictionary' instead of 'anArray'.)
The obvious: is newPoint a valid point? Try this:
NSString *newPointString = nil;
NSPoint newPoint = [anObject determineNewPoint]; // or whatever
newPointString = NSStringFromPoint(newPoint);
NSLog(@"newPointString = %@", newPointString); // see what this prints
out
NSLog(@"ObjectAtKey = %@", [aDictionary objectForKey:newPointString]);
//
and what this does (or if it causes SIGSEV)
--
-- sinclair44
[self becomeWorldDictator];
- (void)becomeWorldDictator
{
[[GeorgeBush principalClass] assassinate:[world currentLeaders]];
[[world citizens] terrorize];
[world setCurrentLeaders:[NSArray arrayWithObject:self]];
}
// Hisaoki "Yuki" Nishida
// <email@hidden>
_______________________________________________
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.