ios - Logical AND with Swift Optional in IF statement -


I have two properties, one of them is optional, these are defined below:

  Var advertiseCompleteBlock: (() - & gt; ())! Var is Advertiser: Boole = Wrong;   

Now, if I try to use it in my code like this below, the compiler throws an error when the error code 254 is created and failed.

  (self advertiser and self replaceable comp block) {self.advertiseCompleteBlock (); }   

But if I change it like this then it works fine:

  if (self.isAdvertiser & self.advertiseCompleteBlock) {If (Self.advertiseCompleteBlock) {self.advertiseCompleteBlock (); }}   

Can someone explain how these two blocks of code are different and what is wrong here?

If advertise is really optional, then maybe it should be declared with someone? Instead ! Who says that it will always come into being.

I put my original code in a test file as a simple function and removed the references of my own and compiled it properly. I do not know what will be the 254 error.

What exactly do you want this code?

  var advertiseCompleteBlock: (() -> ())? - & gt; In fact, the alternative var advertiser is: Bool = false; If (Advertiser & Advertising Complex Block) {advertiseCompleteBlock! (); - & gt; But now is guaranteed)    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -