[Mono-osx] [MonoMac] NSMutableDictionary FromObjectsAndKeys problem

Miguel de Icaza miguel at novell.com
Mon Nov 15 18:47:04 EST 2010


Hello,

> I am working with a mutable dictionary with bindings to an ArrayController
> and am having problems creating a NSMutableDictionary using the
> FromObjectsAndKeys.

Are you running the latest version from GitHub?

On Friday or so, Geoff fixed an important bug with arrays in the Monomac
runtime.

> 
> It works for a NSDictionary but not when creating a NSMutableDictionary.
> 
> The example code below shows what I am talking about.
> 
> 	var objects = new NSObject[3] {new NSString("AAAAA"),
> 						new NSString("BBBBB"),
> 						new NSString("CCCCCC")};
> 
> 	var keys = new NSObject[3] {new NSString("firstkey"),
> 						new NSString("secondkey"),
> 						new NSString("thirdkey")};
> 			
> 	var dict2 = NSDictionary.FromObjectsAndKeys(objects,keys);
> 			
> 	//var dict = NSMutableDictionary.FromObjectsAndKeys(objects, keys);
> 	var dict = NSMutableDictionary.FromDictionary(dict2);
> 			
> 	myContentArray.AddObject(dict);
> 
> The implementation between NSDictionary.cs and NSMutableDictionary.cs are
> different for that method and not sure why.
> 
> Any help would be appreciated
> 
> Kenneth
> 
> ----------------------------------
> If you uncomment the //var dict =
> NSMutableDictionary.FromObjectsAndKeys(objects, keys); it gives the
> following error:
> 
> Stacktrace:
> 
>   at (wrapper managed-to-native)
> MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr_int
> (intptr,intptr,intptr,intptr,int) <0x00004>
>   at (wrapper managed-to-native)
> MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_IntPtr_int
> (intptr,intptr,intptr,intptr,int) <0x00004>
>   at MonoMac.Foundation.NSMutableDictionary.FromObjectsAndKeys
> (MonoMac.Foundation.NSObject[],MonoMac.Foundation.NSObject[],int) <0x00067>
>   at MonoMac.Foundation.NSMutableDictionary.FromObjectsAndKeys
> (MonoMac.Foundation.NSObject[],MonoMac.Foundation.NSObject[]) <0x00028>
>   at NSTableViewBinding.TestWindowController.AwakeFromNib () <0x001f8>
>   at (wrapper native-to-managed) object.92f48794-05ff-4e21-bcf0-61c0dd4bf42b
> (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector) <0x000cc>
>   at (wrapper managed-to-native)
> MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper (intptr,intptr)
> <0x00004>
>   at (wrapper managed-to-native)
> MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper (intptr,intptr)
> <0x00004>
>   at MonoMac.AppKit.NSWindowController.get_Window () <0x00079>
>   at NSTableViewBinding.TestWindowController.get_Window () <0x00012>
>   at NSTableViewBinding.AppDelegate.FinishedLaunching
> (MonoMac.Foundation.NSObject) <0x00038>
>   at (wrapper native-to-managed) object.00860f4e-27a8-4ca0-aa64-ae2828705416
> (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector,MonoMac.Foundation.NSObject)
> <0x00118>
>   at (wrapper managed-to-native)
> MonoMac.AppKit.NSApplication.NSApplicationMain (int,string[]) <0x00004>
>   at (wrapper managed-to-native)
> MonoMac.AppKit.NSApplication.NSApplicationMain (int,string[]) <0x00004>
>   at MonoMac.AppKit.NSApplication.Main (string[]) <0x00015>
>   at NSTableViewBinding.MainClass.Main (string[]) <0x00015>
>   at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object
> (object,intptr,intptr,intptr) <0x00043>
> 




More information about the Mono-osx mailing list