2,623 questions
3
votes
1
answer
1k
views
Leaking C++ shared_ptr in Objective-C Block
Summary:
In the example application below, a shared_ptr is being captured in an Objective-C block. The Objective-C block is being assigned to an ivar of a dynamically created class using the ...
4
votes
1
answer
88
views
Error: Extra parameter in request i used Swift 4. Why i have to pass parameters of type [String: Any]?
Alamofire.request(APPURL.GetAccounts, method: .post,
parameters: transactionData,
encoding: JSONEncoding.default,
headers: nil)....
1
vote
1
answer
1k
views
How can I return a value from a block?
I am quite humbled to admit that I have no clue about blocks.
I am writing a GUI uninstaller app that uses a privileged helper tool delete all of my product's files and directories.
Because the ...
0
votes
1
answer
1k
views
Swift equivalent of my Objective-C block
I can't seem to figure out how to call an Objective-C block from Swift!
I have the following Objective-C method:
- (void)myMethod:(NSDictionary *)selection success:(MyBlock)success;
Where MyBlock is:...
0
votes
0
answers
158
views
Default fullscreen button action event in AVPlayerView Controller in Objective C
I want to retrieve action event of default fullscreen button in AVPlayerViewController. How can i get that button action event? As i want to do edit in that action method. The Fullscreen button will ...
0
votes
1
answer
338
views
Weak/Strong reference within nested blocks
I'm trying to figure out the weakself/strongself reference for nested blocks
What are the difference between:
__weak __typeof__(self) weakSelf = self;
[self.networkCall_1 completionHandler:^(id ...
0
votes
2
answers
121
views
How to end the Completion Block in Next ViewController
I am having the below block in ViewController A
dispatch_async(dispatch_get_main_queue(), ^{
[self dismissAnimated:YES completion:^(BOOL finished) {
[[NSNotificationCenter defaultCenter] ...
1
vote
1
answer
56
views
Objective-C: What does this code mean?
In the MyViewController.h file:
@property (nonatomic, copy, nullable, class) void (^saveMetadataSuccess)(MyViewController*const _Nullable myViewController);
In the MyViewController.m file:
void (^...
0
votes
1
answer
67
views
How to fetch youtube channel list of loggedin user
I want to fetch the youtube channel list and show it on tableView can anyone help to get the channel list of loggedin user via google.
1
vote
1
answer
94
views
How to improve this objective-c code (blocks, RestKit, async, threads)
I'm maintaining an old game code (>5 yrs old) and switched developers hands a few times. Game doesn't has a dedicated player base (an early casino gambling game).
RestKit is used for API calls.
...
1
vote
1
answer
228
views
Change xcode auto indent inside block
I have a (actually a few) quite long api call with a callback block like this:
[[APIsController sharedInstance] submitCaptchaRequestWithParams:param
...
0
votes
2
answers
45
views
Translate recursive JS function into Obj-C
A friend of mine helped me work through a computation problem where I am trying to create a series based on some conditions. He used JS with recursion. I sat down to translate this into Obj-C and am ...
0
votes
2
answers
849
views
Add C function as value to NSDictionary
Upon receiving an NSString, I would like to call a specific code block. I figured an NSDictionary would be best for associating these. Simplified, I'm using something like:
MyProtocol.h:
@protocol ...
0
votes
3
answers
2k
views
How to convert Objective-C block to Swift closure
I have a method that contains an block which defined in Objective - C:
+(void)getNewList:(NewListRequestModel *)model returnInfo:(void(^)(NewListResponseModel* resModel))retModel;
and I invoke it ...
3
votes
1
answer
722
views
Call Method that assigns NSError in Block Crashes
I'd like to understand why this crashes with an EXC_BAD_ACCESS error. It returns from the method call fine, but then crashes immediately afterwards on the [self runMethodThatAssignsError:&error] . ...
2
votes
2
answers
169
views
Performance Differences Capturing External Variables in Blocks via __block vs Not
When bringing externally declared variables into a block...
Using the __block directive captures a variable by reference...
Variables local to the enclosing lexical scope declared with the __block ...
0
votes
1
answer
135
views
Need to wait on completion of setFocusModeLockedWithLensPosition - Semaphore? Atomic? NSCondition?
I’ve not had much experience with semaphores, nor with blocks. I’ve seen various suggestions for how to turn an asynchronous call into a synchronous one. In this case I just want to wait to be sure ...
0
votes
1
answer
78
views
Method initializing an object in a dispatch_sync Block flagged by static analyzer as returning nil
I am unable to figure out why Xcode's static analyzer is giving me the warning "'nil' returned from a method that is expected to return a non-null value". The method is:
- (NSURLSessionUploadTask *)...
0
votes
0
answers
289
views
Get warning when using representationUsingType:NSPNGFileType properties:nil [duplicate]
I were trying to convert a image to NSData and got a below warning. Could you explain to me what is the warning, and how to fix it?
CGImageRef cgRef = [imgView.imageView image];
NSBitmapImageRep *...
-2
votes
1
answer
1k
views
Objective-C: Pass Variable to block
I am very inexperienced with blocks. I have not mastered the syntax.
What I would like to do is to pass a date obtained in the first part of a method into a completion block so that the date is not ...
5
votes
1
answer
610
views
Difference between weak references in a block and a NSTimer
As we know we need to use a weak reference inside a block to break the retain cycle, like so:
__weak id weakSelf = self;
[self doSomethingWithABlock:^() {
[weakSelf doAnotherThing];
}]
However ...
0
votes
3
answers
2k
views
How to wait for the callBack methods (or) response in for loop (Xcode, Objective C, iOS)?
In my code i have multiple locations,I have to check all the locations are correct or not (checking with google api) if location is correct I have to get the coordinates for that location.
I am ...
0
votes
1
answer
76
views
race condition by using __block
I have a list of PHAsset that I need to get their associated URL and do something with each URL. After all the assets are processed I need to perform another task. I try to use __block to count the ...
-1
votes
2
answers
2k
views
What is difference between function/method and block in objective c or Swift
I am learning objective c and swift. i didn't get what is difference between block and method or function in Objective c or in Swift.
int mutiplier=10;
int (^myBlock)(void)=^{
return 10 *3;
};
...
7
votes
3
answers
4k
views
Why does UIAlertController create a retain cycle with self?
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"alert" message:nil preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action = [UIAlertAction actionWithTitle:@"action"...