Does shouldReloadTableForSearchString wait a while before executing? - objective-c

I am implementing search autocommplete. I am doing it without UISearchDisplayController/UISearchBar
A recurring problem is if I start doing something right after the guy press button then the program isn't "snappy".
A way around that is to use timer.
Then I've heard that UISearchController has a delegate to call.
Will that delegate solve my problem? What exactly does the delegate do? Wait a while after pressing button?

My experience is that searchDisplayController:shouldReloadTableForSearchString: is called immediately when the text in the search field changes. So that would not help with your problem.

Related

How to use the XCode documentation

I'd like to listen in to the text change event for an NSTextField, so I looked at the docs and saw a textDidChange event. So, I connect my text field to a delegate and implement the method, run the app, and nothing happens. I also tried textDidEndEditing, but to no avail.
What are these methods for, exactly? How can one trigger them? Changing the text and tabbing out of the field or pressing enter doesn't do anything. After a bit of googling I found a controlTextDidChange method (in the NSControl parent class of NSTextField) so I implemented it, and it worked (though it had to be an override func, not just a plain func).
Handling the text change event in .NET would be a cinch, just switch to the events panel and double click on "changed" and lo and behold, it creates a method stub into which I can handle the event.
Obviously, I'm an XCode newb comparatively. What's the typical way to go about handling events in XCode/Swift? Did I go about it the wrong way, and is there a better/easier way?
Thanks.

Refresh a UIWebView

I'm looking for a simple way of adding a refresh mechanism to my UIWebView. I've seen posts about the EGO pull to refresh but, to be honest, I don't understand how that works, especially since I have no clue on how to use it with a UIWebView instead of a table view. And it seems to me like a lot of overhead for just a simple refresh.
I thought about adding a navbar but instead of a back button, add a custom "refresh" one. But based on what I've found so far, it seems as complicated as the other solution.
So, basically, I'd like to know what you would do. Keep in mind that the only requirement is that the user have some easy way of refreshing the view. Any suggestion ?
*I'm a begginer in Objective-C so that is why I don't understand how to plug the EGO framework with a UIWebView even after downloading and running the code.
Well,
Create a button and inside button's IBAction,
- (IBAction) performReload:(id) sender {
[self.uiwebview reload];
}
Check the documentation, it will help you a lot at your beginning stage.
Visual Suggestion:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html

How to get the last key pressed on Mac?

I'm writing a plugin for an application. I cannot derive from NSApplication
as it is a third party application. I can get the callback in my plugin when any key is pressed. But I will not know what key is pressed. So is there any call in Cocoa to find the last key pressed when I get the callback? I only have NSView object.
Any ideas will help me a lot.
Thanks,
Dheeraj.
A couple of thoughts:
Use [NSApp currentEvent]. I know you don't think you have an NSApplication instance, but you should try this. It might work.
Do some event monitoring in your plugin (CGEventTap, NSEvent local monitor, etc) and record whenever you see a keypress event.

Event path in Mozilla plugin on Mac

I'm writing a mozilla plugin on the mac. I'm trying to capture events like button clicks, etc. I've done the normal thing of creating my views in inteface builder, and linking the sentActions to methods in my program. This works in stand-alone programs.
However, in my NPAPI plugin, those methods never get called. The button reacts, depresses, whatever, but it doesn't do its action.
Instead, the NPP_HandleEvent method gets called, but I never get the MouseDown or MouseUp event, only the UpdateEvt.
I set up the buttons to accept clicks via: (superview is the Mozilla view, topview is the top of my view hierarchy.)
[superView setNextResponder: topView];
[topView setNextResponder: nil];
[browserWindow makeFirstResponder: topView];
NEVER MIND: I'm an idiot. It IS calling the button sent actions. I was looking at the wrong method. That'll teach me to leave around a zoom: method when I'm actually using a doZoom: method... D'oh,.
So, the problem was that I wasn't able to get buttons to work. The buttons were supposed to (for example) zoom an image in an IKImageView. (or rather, zoom the view). It didn't appear that it was working. The screen was flashing a lot, but nothing was happening... I put a printf in my zoom method, and it was NEVER GETTING CALLED! and so I asked the question.
Later, I noticed that I wasn't TRYING to call zoom, I was calling doZoom! doZoom WAS being called. And the reason that it wasn't zooming was an unrelated problem.
The problem ended up being that I was sending setImage to my IKImageView on every event, which re-set the view to 1-1, rightside up mode. Once I took out the extra setImage call, things started to work.
In the unlikely event that anyone else every experiences this, the answer is my cunning plan for world domination:
step 1: Don't be an idiot.
step 2: ???????
step 3: Dominate the world.
(If I could master step 1, I might just be able to figure out what step 2 was B-)

How to be notified of the Minimize button being pressed in an OSX Window?

N.B.: this relates to private (SPI) functions of the CoreGraphicServices framework.
I am currently running a CGSConnection to the Windowserver as the UniversalController (with the Dock killed), and would like to know how I can be notified that a CGSWindow has had the yellow minimize blob clicked.
Is there a notification event that I can watch for with CGSRegisterConnectionNotifyProc?
Perhaps the answer lies in HIToolbox? Any experienced CGS hackers out there have an idea?
Thank you.
CGSGetWindowEventMask or CGSGetWindowGeometry is my best guess but I've never tried my hand at it
NSWindow has this method:
- (BOOL)windowShouldZoom:(NSWindow *) toFrame:(NSRect)proposedFrame
method that you can implement.
Or maybe i don't understand your question...