Advertisement
norswap

SO Answer 2

Dec 12th, 2013
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. You also need to take care with objects passed by reference. The following code will work:
  2.  
  3. NSError *error;
  4. BOOL OK = [myObject performOperationWithError:&error];
  5. if (!OK) {
  6. // Report the error.
  7. // ...
  8.  
  9. However, the error declaration is implicitly:
  10.  
  11. NSError * __strong e;
  12.  
  13. and the method declaration would typically be:
  14.  
  15. -(BOOL)performOperationWithError:(NSError * __autoreleasing *)error;
  16.  
  17. The compiler therefore rewrites the code:
  18.  
  19. NSError * __strong error;
  20. NSError * __autoreleasing tmp = error;
  21. BOOL OK = [myObject performOperationWithError:&tmp];
  22. error = tmp;
  23. if (!OK) {
  24. // Report the error.
  25. // ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement