iOS7 comparison of constant with expression is always false
Asked Answered
L

1

5

In my app that works on iOS 5 and 6 I have an if statement:

NSInputStream *inputStream = [NSInputStream inputStreamWithFileAtPath:sourcePath];
if ([inputStream streamStatus] == NSStreamEventErrorOccurred){
[...]
}

On iOS 7 I get the following warning:

 Comparison of constant 'NSStreamEventErrorOccurred' with expression of type 
'NSStreamStatus' (aka 'enum NSStreamStatus') is always false

Any ideas on what's changed on iOS 7 regarding NSInputstream class? I would like to know why do I receive this warning now on iOS7.

Lexicostatistics answered 5/8, 2013 at 11:2 Comment(1)
iOS 7 is still under NDA, which restrict us from talking about it outside of the developers forum. You might not get as many answers as you might get on the Apple Developers forum.Grandiloquence
M
17

iOS 7 is more particular with enum comparisons. The issue is that you're comparing an NSStreamStatus enumerated value to another, unrelated NSInputStreamEvent value. Instead, try:

NSInputStream *inputStream = [NSInputStream inputStreamWithFileAtPath:sourcePath];
if ([inputStream streamStatus] == NSStreamStatusError){
    [...]
}

This issue has nothing to do with iOS 7 per se, it's just an existing issue you've now discovered thanks to more meticulous warnings.

Merchantable answered 5/8, 2013 at 11:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.