Questions tagged [swift-block]

9 questions
3
votes
1 answer

I get a nil when I use self in block.But self does't free

I use an viewController which inherit BaseViewController. The function "monitorNetworkStatus()" is invoked in BaseViewController's method "viewDidLoad". private func monitorNetworkStatus() { ReachabilityManager.shared.startMonitoring { [weak…
gui
  • 31
  • 2
2
votes
1 answer

Accessing Objective-C block from Swift

I have this Objective-C code in FileManagerHelper: +(void)getMyVideoObject:(NSString *)videoId completion:(void (^)(MyVideoObject *myVideoObject, NSError *error)) completionBlock { } For calling from Objective-C: [FileManagerHelper…
user523234
  • 14,323
  • 10
  • 62
  • 102
1
vote
1 answer

Update label of collection view Cell when I perform some action on the Previous cell and move to the next cell

I have implemented the collection view with two custom cell When I press a button on the first cell then scrolling to the second cell in the collectionviiew but I need to change the value of label which is inside the second cell Let say I have a…
Parth Soni
  • 67
  • 1
  • 6
0
votes
1 answer

Is Weak self required while fetching notification settings of the app

I'm querying notification settings value but I wonder whether [weak self] is necessary. Someone kindly clarify: UNUserNotificationCenter.current().getNotificationSettings { [weak self] appsettings in var mybool = false if…
0
votes
1 answer

Swift ignoring parameter types defined in block signature

I have the code below, which the compiler is happy with: func CheckPaintExists(colorCode : String, applicationCode : String) { let checkRequest = NSFetchRequest(entityName: "Paint") checkRequest.predicate =…
pnizzle
  • 6,243
  • 4
  • 52
  • 81
0
votes
1 answer

Chaining nullable blocks in Objective-C and in Swift?

I need to have a possibility to write: //if someCase1 block1(block2(block3())) //if someCase2 block1(block3()) //if someCase3 block2(block3()) where blocks are some blocks of code. I saw a lot of examples but no one describes how to declare…
0
votes
1 answer

How to write a block to return value from one class to another?

I searched many questions here but seems no one is for the below question. I am trying to create a block completion in Swift. This is an optional variable closure in class X. var onLogCompletion:((_ logThing:String) -> ())? This is the function…
Hemang
  • 26,840
  • 19
  • 119
  • 186
0
votes
0 answers

How to do a recursive block operation Swift

I'm working with alamofire and I make a request (getPrescriptions) when users open the app which is a block with a completionHandler. That function retrieves a list from ws and can be paginated, but I don't know how many items I have at the…
Gehlen
  • 160
  • 1
  • 15
0
votes
3 answers

Join strings in a block

I have a block that updates the view for each String. In its object class I pass it by: func eachFeaturesSection(block: ((String?) -> Void)?) { propertyFeatures.forEach { feature in guard let feature = feature as? RealmString else { return …
Umit Kaya
  • 5,771
  • 3
  • 38
  • 52