Which iOS version supports a valid NSTimer property?

I noticed the strangest thing. I was playing around with NSTimer and while looking through the Apple documentation I reached the property valid

here and noticed that this property is available since iOS 8. This fact in itself is not strange, but the fact is that the number of stackoverflow posts from 4-6 years ago regarding NSTimer are referenced to this property or suggest using it, confused: Example 1 , example 2 , example 3 and many others.

So my question divides by 2:

  • Which iOS versions do support the NSTimer property valid

    ?
  • If I am configured for iOS 7 and above, is it safe to use this property?

Thanks in advance.

+3


source to share


3 answers


Everyone lacks a real story. Have a look at the iOS 8.0 API for NSTimer

(and many other classes).

Apple made a huge refactor by converting many of the APIs to use properties instead of explicit setter / getter methods.

Before iOS 8.0, it NSTimer

had a method named isValid

. In iOS 8.0, Apple removed this method and added a read-only property valid

(declared using the getter method name isValid

.



As a result of this change (and many others like it) in iOS 8.0, the docs make many APIs as if they were just added in iOS 8.0, although they may have been much longer.

The end result is that the documentation is now very misleading for many properties. It is unlikely that submitting an error in the documentation will lead to anything, because this issue applies to many classes and hundreds of properties / methods.

+1


source


Apple's documentation has been updated for Swift, so it has Available in iOS 8.0 and later

for some properties and methods, although they've definitely been there since previous iOS versions. For example, iOS 2.0 was introduced NSTimer

. You can use it safely.



+3


source


I went to the file NSTimer.h

and found

@property NSTimeInterval tolerance NS_AVAILABLE(10_9, 7_0);

- (void)invalidate;
@property (readonly, getter=isValid) BOOL valid;

@property (readonly, retain) id userInfo;

@end

      

Couldn't see NS_AVAILABLE

before property valid

, maybe there are some errors in apple docs

I also gave feedback to fix it.

enter image description here

+1


source







All Articles