【发布时间】:2023-03-22 23:45:01
【问题描述】:
在 MonoTouch 中,我需要处理 NSSet 中的每个对象。我使用 Enumerate 的尝试如下:
public override void ReturnResults ( BarcodePickerController picker, NSSet results )
{
var n = results.Count; // Debugging - value is 3
results.Enumerate( delegate( NSObject obj, ref bool stop )
{
var foundCode = ( obj as BarcodeResult ); // Executed only once, not 3 times
if ( foundCode != null )
{
controller.BarcodeScannedResult (foundCode);
}
});
// Etc
}
虽然在结果中使用三个对象调用该方法,但在委托中只处理了一个对象。我原以为委托会被执行 3 次,但我一定对它的工作原理有错误的想法。
找不到任何文档或示例。任何建议都非常感谢。
【问题讨论】:
标签: xamarin.ios nsset enumerate