Xcode run to wrong method with same signature - ios

I'm encountering some problem with SVPullToRefresh.
I'm trying to debug by placing breakpoints in the library. It's strange that no breakpoint is reached after I run.
Then I place breakpoint at my calling as this:
[self.tableView addPullToRefreshWithActionHandler:^{ // break point at this line
[weakSelf needReloadData];
}];
Then I run debug step into. Wow, what function does it call? It does not call the function in UIScrollView (SVPullToRefresh) in UIScrollView+SVPullToRefresh.m file.
It call the function in UIScrollView(Adobe3SVPullToRefresh) in UIScrollView+Adobe3SVPullToRefresh.m line 115. See the image
What happen with this? Thank you

Related

IOS/Xcode: Breakpoint in completion block possible?

I am trying to debug something going on in a completion block. I put a breakpoint in the completion block, but the code is not breaking. Is it possible to put a breakpoint in a completion block? I recall it being possible but cannot seem to find any confirmation in the docs or on the Internet.
dispatch_async(dispatch_get_main_queue(), ^{
LogDebug(#"ready to save to database if this was new to server");
Items *object = [self.managedObjectContext objectRegisteredForID:myMoID];
//TRIED PUTTING BREAKPOINT RIGHT HERE BUT NOT STOPPING
if (successInt==1) {
object.needsync=#0;
}
});
You should always put a breakpoint on a line where some code is, not an empty line, it works better.
If your log is not printed out in a console, it means your block is never called.
If your code is not breaking this means that your completion block is not being called. Try to print log in completion block to check that if it is being called or not.

XCode not stopping on breakpoint in method called from LLDB

XCode 7.2.1
iPad Retina iOS 9.2 Simulator
I have several breakpoints set in a particular class in an XCode project.
Everything I discuss below takes place in this one class file.
I set the breakpoints on -(int16_t)areaNbr by clicking in the gutter, and set no conditions or anything on them. I confirmed they existed as far as LLDB is concerned by running breakpoint list from the LLDB prompt.
The project scheme is set to build for debugging, not release.
I run the project in the simulator, and stop at a breakpoint in a different method than the one in question, at which time I want to go to the LLDB prompt and call po [self areaNbr] and step through areaNbr.
Please note, as this may be quite relevant, I have NO code in the project itself that calls
-(int16_t)areaNbr
Now, I CAN get this to stop at my breakpoints on -(int16_t)areaNbr if I add some code to the project that calls the method.
For example, if I add something like NSLog(#"... %d", [self areaNbr])
I know the issue has nothing to do with compiling away the method simply because nothing calls it, because if that were true, then my call to po [self areaNbr] wouldn't be spitting out the result to the debugger window as pictured below. So the method is being compiled, and certainly recognized as existing by the debugger for execution purposes... just not for stepping purposes.
FYI, [self area] is returning "Area01"
Calling breakpoint list in LLDB returns the following
By default, lldb does not stop at breakpoints in hand-called code. The majority of folks use expr & expr -O -- i.e. po to print values & objects and were annoyed if they stopped at breakpoints they had set for other purposes.
However, it is easy to control this behavior, just use:
(lldb) expr -i 0 -- [self areaNbr]
Then you will stop at your breakpoint.
In this example, I left out the -O which is the object printing part, since if you just want to call this method, you likely don't care about calling description on the result after the expression is evaluated.
You can see all the options for expression evaluation by doing:
(lldb) help expr

Assertion failed: (result == KERN_SUCCESS), function +[XPCMachSendRight wrapSendRight:]

In my IOS app, I'm sometimes getting the above error after a 3rd party library call, which seems to be allocating some memory, albeit not much (about 13MB);
Assertion failed: (result == KERN_SUCCESS), function +[XPCMachSendRight wrapSendRight:], file /SourceCache/XPCObjects/XPCObjects-46/XPCMachSendRight.m, line 27.
there's no indication where or why this is happening, and I couldn't find any help or even similar problems on the internet. Any ideas?
It happens when we call function before completion of another, i.e. it's threading problem. So check for that. For example:
[self dismissViewControllerAnimated:YES completion:^{
// correct place for code after completion
}];
// wrong place for code after completion

Execute after a function call

I have a function call and some coding statements after the function. These statements should be called only after the function is executed completely How can it be achieved? Currently the statements are executed before the function is executed completely.
For example
NSInteger integerRestValue=[self buttonRestNameTag];
buttonRestNames.titleLabel.text=[[arrayGuessList objectAtIndex:integerRestValue]valueForKey:#"Name"];
Here the buttonRestNameTag function is called and before the execution is completed the buttonRestNames title label is set which cause it to crash.
How can this be resolved?
You may have initialized another Thread inside your function buttonRestNameTag.
Check that thing.
Or Try to use this function :
[self performSelectorOnMainThread:#selector(functionName) withObject:nil waitUntilDone:YES];
Hope this helps.
Edit for Kiron :
Make a variable in class and put returned value in that and access that variable.
This is helpful link to do this
iphone - performSelectorOnMainThread with return value
You can use GCD blocks
Try this.

Check if a method is being executed during runtime

Is it possible to check if a particular method is being executed at a particular point of time on iOS ?
For example, I want to know if the method sampleMethod is being run at 1 minute after the app starts executing?
Can't you use _cmd for that?
NSLog(#"Method name = %#", NSStringFromSelector(_cmd));
Using breakpoints and/or the NSLog(NSString) function inside your mehthods.

Resources