public void IndexOfTest() { var v1 = (NSString)"1"; var v2 = (NSString)"2"; using (var arr = new NSMutableArray <NSString> (v1)) { Assert.Throws <ArgumentNullException> (() => arr.IndexOf(null), "IndexOf ANE"); Assert.AreEqual(0, arr.IndexOf(v1), "IndexOf 1"); Assert.AreEqual(nint.MaxValue, arr.IndexOf(v2), "IndxOf 2"); // [NSArray indexOfObject:] returns NSNotFound = NSIntegerMax when object isn't found in the array } }
public void Unsubscribe(string topic) { if (!connected) { pendingTopics.Enqueue(new Tuple <string, bool>(topic, false)); return; } var deletedKey = new NSString($"{topic}"); if (currentTopics.Contains(deletedKey)) { Messaging.SharedInstance.Unsubscribe($"/topics/{topic}"); nint idx = (nint)currentTopics.IndexOf(deletedKey); if (idx != -1) { currentTopics.RemoveObject(idx); } } NSUserDefaults.StandardUserDefaults.SetValueForKey(currentTopics, FirebaseTopicsKey); NSUserDefaults.StandardUserDefaults.Synchronize(); }