public void NilCallTest() { NSObject pool = new NSObject(NSObject.AllocAndInitInstance("NSAutoreleasePool")); NSObject nil = new NSObject(IntPtr.Zero); // Calling an NSObject method on nil does nothing and returns nil. NSObject result = (NSObject)nil.Call("hash"); Assert.IsTrue(result.IsNil()); // Calling a unknown method on nil does nothing and returns nil. result = (NSObject)nil.Call("foo"); Assert.IsTrue(result.IsNil()); // Can chain calls to nil. result = (NSObject)nil.Call("foo").Call("bar"); Assert.IsTrue(result.IsNil()); // Can use Native with null. result = (NSObject)nil.Call("foo"); Assert.IsTrue(result.IsNil()); pool.release(); }
public void Void3() { IntPtr ip = IntPtr.Zero; NSObject result = ip.To <NSObject>(); Assert.IsTrue(result.IsNil()); }
public void Void2() { NSObject str1 = new Class("NSMutableString").Call("stringWithCapacity:", 12U).To <NSObject>(); NSObject str2 = new Class("NSString").Call("stringWithUTF8String:", Marshal.StringToHGlobalAuto("hey")).To <NSObject>(); NSObject result = str1.Call("appendString:", str2).To <NSObject>(); Assert.IsTrue(result.IsNil()); }
public void memoryTest(NSObject sender) { lock (m_lock) { if (m_checkingMemory) { m_checkingMemory = false; Monitor.PulseAll(m_lock); m_thread1 = null; m_thread2 = null; } else { NSObject app = (NSObject) new Class("NSApplication").Call("sharedApplication"); NSObject window = (NSObject)app.Call("mainWindow"); NSObject content = (NSObject)window.Call("contentView"); NSObject view = (NSObject)content.Call("viewWithTag:", 33); if (!view.IsNil()) { m_thread1 = new Thread(this.DoDumpStatsThread); m_thread1.Start(); m_thread2 = new Thread(this.DoMemoryThread); m_thread2.Start(view); m_checkingMemory = true; } else { Console.WriteLine("Couldn't find the simple layout view."); } } } }