[UIKit] Add nullability to file (#15857)

File did not have nullability enabled. Add nullability and made some
changes to code as safeguards.
This commit is contained in:
Haritha Mohan 2022-09-07 14:58:41 -07:00 коммит произвёл GitHub
Родитель 815d91fbc9
Коммит 35cb9ac366
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 9 добавлений и 7 удалений

Просмотреть файл

@ -11,11 +11,10 @@
#if !WATCH
using System;
using System.Collections;
using System.Collections.Generic;
using Foundation;
using ObjCRuntime;
using CoreGraphics;
#nullable enable
namespace UIKit {
@ -41,9 +40,9 @@ namespace UIKit {
{
var copyOfRecognizers = recognizers;
var savedHandle = Handle;
recognizers = null;
recognizers = new Dictionary<Token, IntPtr> ();
if (copyOfRecognizers == null)
if (copyOfRecognizers.Count == 0)
return;
DangerousRetain (savedHandle);
@ -168,7 +167,10 @@ namespace UIKit {
//
public IEnumerable<Token> GetTargets ()
{
return (IEnumerable<Token>) recognizers?.Keys ?? Array.Empty<Token> ();
var keys = recognizers?.Keys;
if (keys is null)
return Array.Empty<Token> ();
return (IEnumerable<Token>) keys;
}
}