Crash problem with static class, on device only (simulator works)

MarthughieMarthughie GBMember ✭✭
edited November 2015 in Xamarin.iOS

I have a static class whose purpose is to load a number of images into an array so they can be accessed from a number of places without having to call UIImage.FromFile() every time. The class works fine on iPad2 9.1 simulator, but when I try it on iPad2 9.1 Device, an attempt to step into :

Presence2.Init();

just hangs on that line in the IDE, for about 10s and then crashes, disconnecting from the debugger.

I have removed all the code except that which makes the problem happen. If I comment out the line inside the for loop, it is possible to step into Init(). If I uncomment it the App crashes. As I said there are no such problems experienced if running with a simulator.

Am I missing something obvious here ?

public static class Presence2
{
    static UIImage [] m_PresenceImages = new UIImage[4]; 
    //=================================================
    static public void Init()
    {
            for (int i = 0; i < 4; i++)
            {
                m_PresenceImages[i] = new UIImage();
            }
    }
}

Thanks.

Using latest Xamarin Studio, 5.10 (build 871)

Tagged:
Sign In or Register to comment.