Hello, I don't understand what you are trying to achieve. Can you provide an example of the code you would like to have ?
Some useful infos: - CastTo<T>() is a unsafe cast (it throws an exception if the cast fails) - CastAs<T>() is a failsafe cast (returns null if the cast fails) - Class.Name is not reliable because of toll-free (NSCFString, NSCFError, ...) and cluster (NSArray and NSMutableArray both returns NSArray) classes. - Use "IsKindOfClass" message if you want to test class compatiblity. - The wrapper creation/retrieval is done by the generic method GetInstance in ObjectiveCRuntime.Instance.cs. Regards, Laurent Etiemble. 2008/11/26 yoni shalom <[EMAIL PROTECTED]>: > In my scenario, the type is not known until runtime. > Currently, I indeed perform a cast according to a switch on > IdObject.Class.Name, but it would be best if the framework could do this for > me when the wrapper is generated, so that the correct wrapper would be > instantiated instead of Id. > > If you could point me to the area in source where this occurs I'm willing to > take a look and try to think of a patch... > > Thanks, Yoni. > > On Tue, Nov 25, 2008 at 6:29 PM, Laurent Etiemble > <[EMAIL PROTECTED]> wrote: >> >> Hello, >> >> You cannot use .NET keywords reliably on Monobjc wrappers (as they are >> wrappers around native pointers). If you want to cast (safely or not), >> use the CastAs<T>() and CastTo<T>() methods: >> args.objectAtIndex(0).CastAs<NSString>(). >> >> Regards, Laurent Etiemble. >> >> 2008/11/25 yoni shalom <[EMAIL PROTECTED]>: >> > managed class contains : >> > >> > [ObjectiveCMessage("func:")] >> > public Id InvokeApplication(NSArray args) >> > { >> > Console.WriteLine(args.objectAtIndex(0) is NSString); >> > } >> > >> > There is a call from objective c to this function, using an NSArray >> > which >> > contains an NSString. >> > >> > if that NSString in objective-c is an empty string (i.e. ""), the result >> > of >> > running this code is "true" >> > if that NSString in objective-c isn't empty (i.e. "bla"), the result of >> > running this code is "false", which in my scenario is a problem. >> > >> > Any suggestions? Workarounds? >> > > >