Pregunta

I've been looking at this issue we are having with an iOS app and it's webservice class. It seems that the class gets initialized and assigned an instance, but when we try to trigger the class by starting a timer button, it seems the instance has been removed from memory. This is how we initialize (and try to get an instance from) the class.

+ (ReflexionsMetaWebService *)getInstance
{
    static ReflexionsMetaWebService *instance;
    static dispatch_once_t onceToken;

    dispatch_once(&onceToken, ^{
        instance = [[ReflexionsMetaWebService alloc] init];
    });
    return instance;
}

I've determined that the button that's calling the class is working as intended by cleaning the references as mentioned in other topics on this forum. Is there maybe a cleaner way to initialize and maintain our webservice class instance?

¿Fue útil?

Solución 2

We found the issue for the issue. Apparently the class was still instantiated, but a string was wrongly cast during the process. Our inexperience with the error-message led us to think it has something to do with the instantiation.

Thanks you for your answers!

Otros consejos

I think you are assigning this instance to an object that gets released from the memory. I don't think you have problem with your webservice class, by the look of it. Put a log message to check your class reference and the assigned reference before the timer kicks in and see where the problem is.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top