Hello Steve, Using `is` and `GetType` is the best - but it's not always possible.
There's a similar question (and several answers) on stackoverflow that cover this. http://stackoverflow.com/q/11655354/220643 Sebastien On Fri, Aug 17, 2012 at 11:31 AM, Nic Wise <[email protected]> wrote: > It appears to return the class name. So, if subview is a UIViewController: > > NSStringFromClass([subview class]) > > would return "UIViewController" > > Easiest way to do this in MT would be: > > subview.GetType().Name > > Or possibly one of the other methods on GetType. FullName would return > MonoTouch.UIKit.UIViewController, and I think name just returns > "UIViewController" > > you may also be able to use "is", which is built into the framework: > > if (subview is UITableViewCellDeleteConfirmationControl) { > .... > } > > this should do the same, but MAY look up the tree (eg subview is > Object would always be true, as everything is an Object) > > > > > On Fri, Aug 17, 2012 at 10:42 AM, stevek <[email protected]> wrote: >> I am trying to port some iOS code such as >> >> if ([NSStringFromClass([subview class]) >> isEqualToString:@"UITableViewCellDeleteConfirmationControl"]) >> >> to the equivalent monotouch but I am a bit stuck with the NSStringFromClass >> method. Any ideas? >> >> The sort of effect I am trying to achieve is here: >> http://stackoverflow.com/questions/2104403/iphone-uitableview-delete-button >> >> I have used the following bit of debugger inspection & hackery but I suspect >> it would not survive a new version of iOS or monotouch. >> >> if (subview.ClassHandle == new IntPtr(0x118780c)) >> >> >> >> >> >> >> >> -- >> View this message in context: >> http://monotouch.2284126.n4.nabble.com/NSStringFromClass-equivalent-in-monotouch-tp4656555.html >> Sent from the MonoTouch mailing list archive at Nabble.com. >> _______________________________________________ >> MonoTouch mailing list >> [email protected] >> http://lists.ximian.com/mailman/listinfo/monotouch > > > > -- > Nic Wise > t. +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise > b. http://www.fastchicken.co.nz/ > > mobileAgent (for FreeAgent): get your accounts in your pocket. > http://goo.gl/IuBU > Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa > Earnest: Self-employed? Track your business expenses and income. > http://earnestapp.com > Nearest Bus: find when the next bus is coming to your stop. > http://goo.gl/Vcz1p > London Bike App: Find the nearest Boris Bike, and get riding! > http://goo.gl/Icp2 > _______________________________________________ > MonoTouch mailing list > [email protected] > http://lists.ximian.com/mailman/listinfo/monotouch _______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
