Variable global en iOS

I need to create a variable in iOS that will store a time value and keep it stored for the next time a function is triggered.

What I'm trying to do is real-time analysis on the battery level. So it will take a time reading, wait till the monitor is fired for battery change compare the time stored to new time and from that work out how much time is passing per 1% of battery usage.

What's the best way to create and use a variable like this in Objective C, and what type should it be?

preguntado el 10 de marzo de 12 a las 02:03

1 Respuestas

Debería ser NSDate. In the world of Cocoa, a date is an exact instant in time, unrelated to any specific calendar or expression.

You'd want to store it as an instance variable of the class with the relevant logic inside it, possibly writing it out and reading it back from the NSUserDefaults if you want it to persist between application launches.

respondido 10 mar '12, 02:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.