IOS: Using A Pattern Image As A Background -Memory Leak

前端 未结 3 1517
没有蜡笔的小新
没有蜡笔的小新 2021-01-15 15:20

OK. I\'ll be looking for the answer, and may find it myself. I have a nasty habit of answering my own questions.

In any case, I have an app that is designed to be \"

3条回答
  •  梦毁少年i
    2021-01-15 15:35

    The best way to initilise your shared colour is like this:

    + (UIColor *)color
    {
        static UIColor *color;
        static dispatch_once_t onceToken;
        dispatch_once(&onceToken, ^{
            color = [[UIColor alloc] init...];
        });
        return color;
    }
    

    It is thread safe and only initialises the colour once. That way there is no way that you can leak the colour.

提交回复
热议问题