Skip to content

Instantly share code, notes, and snippets.


Jan Chaloupecky JanC

  • N26
  • Berlin
View GitHub Profile
View SwiftUIRepresentable.swift
import SwiftUI
import Combine
struct MyContentView: View {
@State var isPresentingModal = false
// comment this out
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
View SwiftUI.swift
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 = {
JanC /
Last active January 29, 2018 16:38


A pseudo implememntation of a mvvm with different cell types in the same section. The table view displays a mixed list of User profiles and their Posts.

Each section's 1st row is the profile of a user and the next cells in that section are the posts of that user

// MARK: -  Models
JanC / q3.m
Created August 12, 2015 13:27
View q3.m
NSOperation *operation = [[NSOperation alloc] init];
__weak typeof(operation) weakOperation = operation;
operation.completionBlock = ^{
__strong typeof(operation) strongOperation = weakOperation;
if (strongOperation.isCancelled) {
// do something
JanC / q2.m
Created August 12, 2015 13:27
View q2.m
NSOperation *operation = [[NSOperation alloc] init];
operation.completionBlock = ^{
if (operation.isCancelled) {
// do something
JanC / q1.m
Created August 12, 2015 13:26
View q1.m
NSObject *test;
NSArray *someArray = @[ @1, @2, @3 ]; // sample array
[someArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
test = obj;