Hello,
I think your method signature is wrong. It should returns an Id:
[ObjectiveCMessage("tableView:objectValueForTableColumn:row:")]
public *Id *objectValueForTableColumn(NSTableView aTableView, NSTableColumn
aTableColumn, int rowIndex)
See NSTableDataSource reference to get the signatures (
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Protocols/NSTableDataSource_Protocol/Reference/Reference.html#//apple_ref/doc/uid/20000122-BCIJJEBC
)
Regards, Laurent Etiemble.
2008/11/27 Mario De Clippeleir <[EMAIL PROTECTED]>:
> Hi,
>
> This is still not working... The same error exists...
>
> This is the method that causes the error :
>
>
> [ObjectiveCMessage("tableView:objectValueForTableColumn:row:")]
> public object objectValueForTableColumn(NSTableView
> aTableView,NSTableColumn aTableColumn,int rowIndex)
> {
> Console.WriteLine("get Object");
> Console.WriteLine(items[rowIndex]);
> NSString testString = (NSString) items[rowIndex];
> Console.WriteLine(testString.Length);
> return testString;
> }
>
> Thanks,
>
> Mario
> On 26 Nov 2008, at 18:57, Laurent Etiemble wrote:
>
>> Hello,
>>
>> You must return a subclass of Id, thus a NSString instead of String.
>> Cast it to NSString (there is an implicit conversion).
>>
>> Regards, Laurent Etiemble.
>>
>> 2008/11/26 Mario De Clippeleir <[EMAIL PROTECTED]>:
>>>
>>> Hi,
>>>
>>>
>>>
>>> I am trying to bind a DataSource to a TableView, but when trying to get
>>> the
>>> objectValueForTableColumn, I get an error :
>>>
>>> """"
>>>
>>> item added
>>>
>>> numberOfRows call
>>>
>>> reloaded
>>>
>>> get Object
>>>
>>> Stacktrace:
>>>
>>> at (wrapper managed-to-native) Monobjc.Dynamic.Messaging.OBJC_MSGSEND
>>> [System_Void]().objc_msgSend (intptr,intptr) <0x00004>
>>>
>>> at (wrapper managed-to-native) Monobjc.Dynamic.Messaging.OBJC_MSGSEND
>>> [System_Void]().objc_msgSend (intptr,intptr) <0xffffffff>
>>>
>>> at (wrapper runtime-invoke) Monobjc.Dynamic.Messaging.OBJC_MSGSEND
>>> [System_Void]().runtime_invoke_void_intptr_intptr
>>> (object,intptr,intptr,intptr) <0xffffffff>
>>>
>>> at (wrapper managed-to-native)
>>> System.Reflection.MonoMethod.InternalInvoke
>>> (object,object[],System.Exception&) <0x00004>
>>>
>>> at (wrapper managed-to-native)
>>> System.Reflection.MonoMethod.InternalInvoke
>>> (object,object[],System.Exception&) <0xffffffff>
>>>
>>> at System.Reflection.MonoMethod.Invoke
>>>
>>>
(object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo)
>>> <0x000b5>
>>>
>>> at System.Reflection.MethodBase.Invoke (object,object[]) <0x00020>
>>>
>>> at Monobjc.Generation.MessagingGenerator.SendMessage
>>> (string,intptr,intptr,object[]) <0x0010b>
>>>
>>> at Monobjc.ObjectiveCRuntime.SendMessage
>>> (Monobjc.IManagedWrapper,string,object[]) <0x00070>
>>>
>>> at Monobjc.Cocoa.NSApplication.Run () <0x0002b>
>>>
>>> at Monobjc.Cocoa.NSApplication.RunApplication () <0x0004b>
>>>
>>> at TestCocoaGui.Program.Main (string[]) <0x00034>
>>>
>>> at (wrapper runtime-invoke)
>>> TestCocoaGui.Program.runtime_invoke_void_string[]
>>> (object,intptr,intptr,intptr) <0xffffffff>
>>>
>>> Abort trap
>>>
>>> """
>>> What causes this ? The object i am returning is a string...
>>> Thx,
>>> Mario
>>>
>>>
>>>
>>>
>>>
>>> From: Duane Wandless [mailto:[EMAIL PROTECTED]
>>> Sent: vrijdag 21 november 2008 16:51
>>> To: [email protected]
>>> Subject: Re: [EMAIL PROTECTED] Data binding
>>>
>>>
>>>
>>> Not knowing what you have accomplished already I will briefly describe
>>> what
>>> I have done. When I find time I'll post something with pictures. My
>>> main
>>> application is a Cocoa ObjC app that controls the GUI. When the app
>>> starts
>>> the very first thing I do is load my C# EXE, note not a DLL. A
bug/issue
>>> exists that loading a DLL does not completely init the mono environment.
>>>
>>> Using Monobjc I export my C# classes to the Cocoa world. This is why
the
>>> mono executable must be properly initialized first, so that when the NIB
>>> files are loaded by Cocoa it will find my registered mono classes.
>>>
>>> In the NIB file I add an NSObject and set the class to be the name of my
>>> C#
>>> class, say MonoObject. Add some class outlets to the MonoObject in the
>>> NIB
>>> file that point to array/tree controllers within that NIB file. The
tree
>>> controller's mode should be class and the class name most likely will be
>>> NSMutableDictionary, though it can be a class defined in mono as well.
>>> You
>>> can add keys to these controllers to make binding easier on the table
>>> views. Speaking of the table views, you simply point them to the tree
>>> controller and bind as usual.
>>>
>>> Back in your C# class you will have a NSTreeController variable that is
>>> hooked up by monobjc to the tree controller in the NIB file. Whenver
>>> appropriate you can, from within C#, clear the tree controller data, add
>>> data, remove data etc. I call something like
>>> treeController.addObject(<myobject>) where myobject is an instance of a
>>> C#
>>> class. That class then must register the methods to expose the keys you
>>> have setup in the tree controller.
>>>
>>> You most likely will need to send a reload data notification to the
views
>>> that use these tree controllers. So you should also set class outlets
>>> that
>>> point to these views so that you can send them reload data messages.
>>> PostNotification is a nice way to send messages to your mono class so
>>> that
>>> it can load the data as needed.
>>>
>>> Another solution is to set your table view's/outline view's datasource
to
>>> be
>>> MonoObject. Just provide the datasource methods in your C# class. I
>>> have
>>> not implemented this way but I think I'm leaning toward switching.
>>>
>>> Not a lot of detail here but hopefully it helps.
>>> Duane
>>>
>>> On Fri, Nov 21, 2008 at 9:44 AM, Mario De Clippeleir <[EMAIL PROTECTED]>
>>> wrote:
>>>
>>> Hi,
>>>
>>>
>>>
>>> I am trying monobjc to port an existing .NET application to the Mac. I
>>> would
>>> like to use a DLL in which an object model resides. When loading a file,
>>> the
>>> object model is being filled. This logic is all in the library.
>>>
>>> Now, my question is : if I want to use binding for the Mac gui, do I
need
>>> the "wrap" the object classes from the library into Managed object
>>> classes ?
>>> What would be the best way to handle this ?
>>>
>>>
>>>
>>> On another note : In the latest monobjc distribution, I can't seem to
get
>>> the TwoManyControllers project working. "The document
>>> TwoManyControllers.exe
>>> could not be opened. TwoManyControllers cannot open files in the EXE
File
>>> format."
>>>
>>> I mean, it loads up, but you can't do anything…
>>>
>>> Does anyone else has this problem ?
>>>
>>>
>>>
>>> Thanks,
>>>
>>>
>>>
>>> Mario
>>>
>>>
>
>