Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Why does the value of an NSIndexPath change

$
0
0

I have seen this problem multiple times so I created a simple app to demonstrate. Here it is:
using System;
using Foundation;
using UIKit;

namespace nsindexpathbug.iOS
{
public partial class ViewController : UIViewController
{
public ViewController(IntPtr handle) : base(handle)
{
}

    public override void ViewWillAppear(bool animated)
    {
        base.ViewWillAppear(animated);

        var indexPath1 = NSIndexPath.FromRowSection(1, 1);
        var indexPath = NSIndexPath.FromRowSection(1, 1);

        BeforeLabel.Text = $"section = {indexPath.Section} row = {indexPath.Row}";
        indexPath1.Dispose();
        AfterLabel.Text = $"section = {indexPath.Section} row = {indexPath.Row}";
    }

    public override void DidReceiveMemoryWarning()
    {
        base.DidReceiveMemoryWarning();
        // Release any cached data, images, etc that aren't in use.
    }
}

}

and here is the results:


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>