Swift 4.1 error with NS Predicate EXC_BAD_ACCESS (code=1, address=0x1)

Hi


I'm hoping that someone can assist here as I cannot work this one out and the Easter holiday weekend has already passed me by trying to resolve this.


I have had no previous issues with this code in previous versions of xcode.


However, installed 9.3 at the tail end of last week and a issue has appeared.


The line of code that throws the error is a boolean predicate with all other predicates seemingly working as usual.

Other lines with similar boolean conditions also give this error.



let Currentpredicate1 = NSPredicate(format: "%K == %@", "managed", true as CVarArg)


Having tried to find info as well as various formats, for example,


let Currentpredicate1 = NSPredicate(format: "managed == %@", true as CVarArg)


Yet I cannot solve this issue.


Please can anyone help or point me in the right direction of a solution?


Kindest regards,

AD

I'm not much familiar with predicates, but I understand the format should be:


let Currentpredicate1 = NSPredicate(format: "%K == %@", NSNumber(value: true))


See here:

h ttps://stackoverflow.com/questions/6169121/how-to-write-a-bool-predicate-in-core-data/34631602

This removes the error however doesn't explain what is happening so that no query with a boolean predicate now works in 9.3 whilst the previous code worked in all versions up to 9.3. I was looking to see if this Swift/XCode update had deprecated something in this area but didnt seem obviously that that was true.


Very confusing. Fixable obviously albeit with 100s of lines to change. It isn't however clear why this has happened?!

Was it working in 9.2, without any warning ?


What has changed overtime in Swift is the deprecation of implicit type conversion. May be that's what is happening here ? But that was already in Swift 3.

That's the assumption I'm working on and that somewhere in here is that the depracation is somehow being forced somewhere. Either way I can see the problem. Thanks 🙂

Good. Don't forget to marked the thread as closed.

I’m glad you found a workaround but I still think you should file a bug about this. Swift has a high source compatibility bar, and especially so in dot releases like this one, so seeing a failure like this show up at runtime is not good.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

For Swift 5 you I think you can use let Currentpredicate1 = NSPredicate(format: "managed == true")

Swift 4.1 error with NS Predicate EXC_BAD_ACCESS (code=1, address=0x1)
 
 
Q