Bil*_*llF 1 enumerate nsset xamarin.ios
在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
}
Run Code Online (Sandbox Code Playgroud)
虽然在结果中使用三个对象调用该方法,但在委托中只处理一个对象.我本来希望代表被执行三次,但我必须错误地了解它是如何工作的.
无法找到任何文档或示例.任何建议都非常感谢.
您必须将ref参数设置为false.这指示处理程序继续枚举:
if ( foundCode != null )
{
controller.BarcodeScannedResult (foundCode);
stop = false; // inside the null check
}
Run Code Online (Sandbox Code Playgroud)
这是来自Apple文档的ObjC等价物.
| 归档时间: |
|
| 查看次数: |
374 次 |
| 最近记录: |