Ejemplo n.º 1
0
    public void Block()
    {
        if (ExtendedBlock.HasBlocks())
        {
            NSObject s = new Class("NSString").Call("stringWithUTF8String:", Marshal.StringToHGlobalAuto("hello\nthere")).To <NSObject>();

            var        lines = new List <string>();
            Enumerator e     = (IntPtr context, IntPtr line, ref byte stop) =>
            {
                lines.Add(new NSObject(line).Call("description").ToString());
            };
            var block = new ExtendedBlock(e);
            s.Call("enumerateLinesUsingBlock:", block);

            Assert.AreEqual(2, lines.Count);
            Assert.AreEqual("hello", lines[0]);
            Assert.AreEqual("there", lines[1]);
        }
    }