Questions tagged [objective-c-blocks]
Blocks are Apple’s implementation of closures for C, which are also available for Objective-C and C++.
objective-c-blocks
2,626
questions
0
votes
0
answers
44
views
Why is my Swift function not printing from inside the dataTask closure? [duplicate]
I am trying to learn about making http requests using Swift but for some reason i cannot get the getPosts() method to print anything. It keeps skipping over the dataTask and prints after it. I ...
0
votes
0
answers
53
views
Behavior of __block modifier in objc [duplicate]
We know __block makes blocks not retain the objects, but why this happens:
#import "ViewController.h"
@interface TestClass : NSObject
@end
@implementation TestClass
- (void)dealloc {
...
1
vote
2
answers
188
views
convert gcc forward-declared nested function to clang blocks
I know this is impossible because I've spent hours on it and also read these below but I am determined to approximate a clang block forward definition even if it takes linker tricks or inline assembly:...
0
votes
1
answer
60
views
Purpose of code blocks in this Objective-C method
I'm newish to objective C and and have a question about code from this example project from Apple showcasing some Metal features.
The code contains a few blocks sitting inside of the function scope. ...
0
votes
1
answer
25
views
how to check if scrollView grinds to a halt when tabbar is clicked?
A viewcontroller is the child of tabbarcontroller, it has a tableview, when the tableview grinds to a halt, one of three methods is executed.
- (void)scrollViewDidEndDragging:(UIScrollView *)...
0
votes
1
answer
49
views
Block mutates a variable that is indirectly in it's scope
This is the most minimal example I could think of:
#import <Foundation/Foundation.h>
@interface ObjCClass:NSObject
@property void (^aBlockInner) ();
-(void)method;
-initWithBlock:(void (^)())...
1
vote
1
answer
100
views
How to share a block between MRC and ARC code?
I have a piece of ARC code written in Objective-C that is creating a block and will want to provide it to some Objective-C MRC code as a callback, to be called when an operation finishes. What is the ...
1
vote
0
answers
117
views
Qt iOS app crash in completion handler callback with EXC_BAD_ACCESS
I'm writing a Qt app on iOS which uses the MLKit FaceDetector. I have a FaceDetector class which has the following method:
void FaceDetector::runFaceDetection(const QImage &image)
{
// ...
3
votes
0
answers
2k
views
What is iOS's block_destroy_helper function?
I noticed a function named block_destroy_helper in this crash log from my iOS app. I want to know more what is this function, but I can't find any useful information. I just want to know the ...
2
votes
0
answers
35
views
Is the number before selector name in crash log meaningful to developer?
Sometimes, we can see some log trace with line number as 0 as the following:
Thread 21 Crashed:
0 libobjc.A.dylib 0x00000001a04cf28c objc_release + 16
1 MyApp ...
4
votes
1
answer
838
views
Calling block from Objective C collection in Swift
I have a Swift object that takes a dictionary of blocks (keyed by Strings), stores it and runs block under given key later at some point depending on external circumstances (think different behaviours ...
0
votes
0
answers
508
views
Crash with [NSOperationBlock dealloc]
There is a crash in the application I am working on. The following is the crash log:
Exception Type: SIGSEGV
Exception Codes: SEGV_MAPERR at 0xf86985380
Crashed Thread: 4
Thread 4 Crashed:
0 ...
0
votes
1
answer
567
views
Pass Objective-C block or method as C-function pointer
I'm using https://github.com/nodejs/http-parser, the callbacks it uses are like this
struct http_parser_settings {
http_cb on_message_begin;
http_data_cb on_url;
http_data_cb on_status;
...
4
votes
1
answer
65
views
Objective-C: Why two requests of [object copy] return the same result?
I would expect copy on an object to generate a new object. But it seems it will only generate a different one and may reuse it for another copy.
void (^block1)(void) = ^ {
// ...
};
void (^block2)(...
2
votes
2
answers
130
views
Will weak pointer in a block become dangling when I refer it with stong pointer in OC?
as the question described, will the wSelf in block become dangling?
1 void bindDefaultCallbacks {
2 __weak typeof(self) wSelf = self;
2 [sessionManager setDataTaskDidReceiveDataBlock:^(...