Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-c code equal to guard

I have been implementing the home kit app in objective-c . I have converted all the swift code but stoped at one line called

guard let metadata = metadata else { return false }

Could any one please guide me to write the objective-c code equivalent to the above line of code. Thank you so much for reading my post.

like image 316
SRI Avatar asked Dec 19 '22 22:12

SRI


1 Answers

From a compiler perspective there is no exact equivalent, because the guard statement else block is guaranteed to return control (i.e., the guard statement must be true for the code to continue past the guard). You can read more about it here.

The closest you can get is:

if(metadata == nil) { return NO; }
like image 169
Charles A. Avatar answered Dec 24 '22 00:12

Charles A.