cocoa

Graying out an NSWindow's content

I have an NSWindow with 2 NSViews (an NSSplitView and a custom NSView). Accessing the data to populate these views can take some time. During this period, I'd like to gray out the content of these views. My first approach was to have a black third NSView that covered the other 2 and achieve the graying out effect by changing its alpha ...

Strip Non-Alphanumeric Characters from an NSString

I'm looking for a quick and easy way to strip non-alphanumeric characters from an NSString. Probably something using an NSCharacterSet, but I'm tired and nothing seems to return a string containing only the alphanumeric characters in a string. ...

Xcode 3.2 find and replace in selected text

Is it possible to find and replace in selected text in Snow Leopard Xcode 3.2? There always use to be an option for selected text. Really frustrating. Thanks. ...

Which Objective-C framework do I have to use to record my screen?

I'm already recording from my iSight from a python script using the pyobjc bridge and the QTKit framework. Which framework/device/... should I use to capture the video of my screen instead of the built-in iSight? P.S. I'm using Leopard (not Snow Leopard) and thus I don't have the Quicktime X API at my disposal. ...

Cocoa NSStatusBar Global HotKey

I have created an NSStatusBar cocoa application which sits in the system status bar. I want to assign a hotkey so that when pressed it toggles my applications and show the menu. Is this possible?, In my searching and experimenting I have found a few different ways of assigning global hot keys that can be pressed when your application i...

Handling timeouts in Webview

Suppose you have a webview that would load a page, how would you handle the situation if the page fails to load, for instance, in 20 seconds? More specifically which WebView delegate method is called when the such situation occurs? - (void)webView:(WebView *)sender didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)f...

How can I tell my Cocoa application to quit from within the application itself?

I'm looking for a good way to tell my Cocoa application to quit itself. Rest assured that this will not be used for production code. I'm just looking for an easy way to run one test and then close the application during debugging. I have found that exit(0); will close the app, but it bypasses all of the normal application exit procedure...

NSMutableURLRequest modifying header fields

NSMutableURLRequest apparently changes case on header fields. For example, setting: [request addValue:myValue forHTTPHeaderField:@"FOOBAR"]; will change the header field to "Foobar". Anybody know a way around this? I am working with a service that requires a case sensitive field to be passed. Also, NSMutableURLRequest shouldn't rea...

Cocoa - problem with this code using NSBundle

It was suggested that I use this line of code to call an image from my resources folder/project bundle. I also see it being used exactly like this on many different website tutorials. NSBundle *mb=[NSBundle mainBundle]; NSString *fp=[mb pathForResource:@"topimage" ofType:@"PNG"]; NSImage *image=[NSImage initWithContentsOfFile:fp]; ...

NSMutable Array - objectAtIndex: index beyond bounds

Hi everyone, I'm trying to look through a NSMutableDictionary loaded with an NSMutableArray and I'm messing it up, and I don't know how. I'm trying to load a larger plist of game questions, then delete them if they aren't the right level. I don't get an error until I try and delete. Can anyone see the flaw in this code? I'd super ap...

Cocoa : Refresh NSObjectController after unarchiving Data from disk.

I have an Object bound to the user interface with a NSObjectController. I am able to archive the Object and unarchive it later. This works fine so far. In the Debugger I can see the object holds the data I saved in a previous session. The remaining problem is: The user interface does not refresh. I guess I have to tell the NSObjectContr...

NSManagedObjectContextObjectsDidChangeNotification userInfo Dictionary.

I am using the NSManagedObjectContextObjectsDidChangeNotification notfication in my app, I already now how to use it. As I have used the below code to add the observer … - (void) awakeFromNib { NSNotificationCenter *nc; nc = [NSNotificationCenter defaultCenter]; [nc addObserver:self selector:@selector(syncKVO:) name:N...

Distinguishing a single click from a double click in Cocoa on the Mac

I have a custom NSView (it's one of many and they all live inside an NSCollectionView. I don't think that's relevant, but who knows?). When I single-click the view, I want it to change its selection state (and redraw itself accordingly); when I double-click the view, I want it to pop up a larger preview window for the object that was jus...

How to custom draw window title bar in Objective-C?

I'd like to customize the way I draw the window title bar on OS X. Specifically, I'd like to do something like the Twitterrific app where there is a custom close button, no min/max buttons, and the window title text is right-justified. Unlike Twitterrific, I'm not looking to custom draw the entire window (though I'm not completely oppose...

NSMutable Array

Hello, I have a NSMutableArray: NSMutableArray *temp = //get list from somewhere. Now there is one method objectAtIndex which returns the object at specified index. What I want to do is that, I want to first check whether an object at specified index exists or not. If it exists than I want to fetch that object. Something like: if (...

How to find out if there is an "." in an NSString?

Have got an NSString *str = @"12345.6789" and want to find out if there is that "." character inside of it. I'm afraid that there are ugly char-encoding issues when I would just try to match an @"." against this? How would you do it to make sure it always finds a match if there is one? I just need to know that there is a dot in ther...

Predicate to sum child's value

I'm trying to get total salary for the whole company by: NSNumber *totalSalary = [company valueForKeyPath:@"[email protected]"]; But I keep getting this error, "-[__NSSet0 decimalValue]: unrecognized selector sent to instance 0x10031eb00". I think I'm doing something wrong but I'm not sure where. ...

Fetch data by date range using Interface Builder

I have an NSTableView that is done using the typical IB and data bindings. It works well. However I need to put in a Segmented Control to indicate date range. So for example, if user clicks on the "Last Year" segmented control button, the table should only display records for last year. I looked at the data binding options in IB for th...

How to get an string representation from an NSDecimal without any formatting?

For example, I have an NSDecimal myDecimal. Lets say it represents something like "-1234567.89" How can I get a clean string representation of that decimal without any beautification / formatting? No localization? Floating point symbol = . and rest only numbers from 0 to 9, and eventually an - if it is negative? I need that string in st...

Encoding problem in sqlite and objective-c

I have a file with contents something like this: INSERT INTO table VALUES (NULL,'° F','Degrees Fahrenheit'); INSERT INTO table VALUES (NULL,'° C','Degrees Celsius'); Now, to parse this, I have something like this: NSString *sql = [NSString stringWithContentsOfFile:filename]; Printing this string to the console looks correct. Then,...