Re: Storing objects in NSMutableDictionary
Re: Storing objects in NSMutableDictionary
- Subject: Re: Storing objects in NSMutableDictionary
- From: Geoffrey Holden <email@hidden>
- Date: Sat, 14 Aug 2010 17:16:21 +0100
This initWithApp bit works fine - I just can't store what I've created
(but I'll post the code later, just as soon as I get back to my other
computer). I can use the object directly, but if I step through the
code to the part where it attempts to store it in the mutable
dictionary currentMessages, that code won't execute - it won't step
over that code. It just seems to exit the debugger.
The message I seem to be getting here though is that it should be
possible to store any object, even an object which contains methods,
in an NSDictionary. In all honesty, even that information is
incredibly helpful because it tells me that I'm not wasting my time by
trying to get it to work. It's odd though that it'll store into an
NSArray (using addObject) with no difficulty, but it doesn't seem to
like setObject: forKey into an NSDictionary.
Thank you for all your efforts!
On 14 Aug 2010, at 09:23, email@hidden wrote:
On 14 Aug 2010, at 09:08, Geoffrey Holden wrote:
The class object is 'message' and its key 'messageID' is an
NSString. If I set the object to be an NSString (or NSArray or
NSDictionary), the dictionary stores it just fine. It just won't
store 'message'.
Won't store means 'what'? Is an exception raised.
If message or messageID is nil the NSMutableDictionary will raise.
messageID is, in reality, generated elsewhere. But you could
imagine it to be NSString* messageID with a value of, say,
@"FirstDocument". Messenger refers to a nib file with which
message is initialized. And I know that my method name
(initWithApp) might be a bit rubbish, but I can always refactor
later!
NewMessage* message = [[NewMessage alloc]
initWithApp:@"Messenger" :self];
[currentMessages setObject:message forKey:messageID];
Message isn't a class object, it's an instance of the NewMessage
class.
Plus the method signature looks wonky.
Post the code for NewMessage initWithApp: if you are still having
problems.
Regards
Jonathan Mitchell
Developer
Mugginsoft LLP
http://
www.mugginsoft.com_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden