This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NSObject *test; | |
| NSArray *someArray = @[ @1, @2, @3 ]; // sample array | |
| [someArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { | |
| test = obj; | |
| }]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NSOperation *operation = [[NSOperation alloc] init]; | |
| operation.completionBlock = ^{ | |
| if (operation.isCancelled) { | |
| // do something | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NSOperation *operation = [[NSOperation alloc] init]; | |
| __weak typeof(operation) weakOperation = operation; | |
| operation.completionBlock = ^{ | |
| __strong typeof(operation) strongOperation = weakOperation; | |
| if (strongOperation.isCancelled) { | |
| // do something | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| /// If _anything_ changes in the `MainView` (e.g. Timer update), its `var body` is re-created and therefore a new instance of `DetailsView(presenter: DetailsViewPresenter())` is created (even if it is already pushed) | |
| /// A new instance of `DetailsViewPresenter` has `isChecked` set to false so the checkbox is unchecked even if view is already presented | |
| struct MainView: View { | |
| let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect() | |
| let formatter: DateFormatter = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| import Combine | |
| struct MyContentView: View { | |
| @State var isPresentingModal = false | |
| // comment this out | |
| @Environment(\.presentationMode) var presentationMode: Binding<PresentationMode> |