cocoa

Map Custom URL protocol to HTTP (using NSURLProtocol?)

I have an application using a WebKit WebView and I'd like to map URL's that are loaded in this WebView with a custom URL protocol to a different HTTP URL. For example, say I am loading: custom://path/to/resource I would like to internally actually load: http://something-else.com/path/to/resource In other words, the custom protocol se...

How to read XHTML file tags using Objective-C?

Hi, I want to read XHTML tags and text separately using objective C. what approach I have to follow? ...

How do I open an NSWindow and have the window selected and in focus?

I am trying to open a NSWindow using the following code: NSWindowController *window = [[NSWindowController alloc] initWithWindowNibName:@"MainWindow"]; [window showWindow:nil]; The window opens okay but the previous window is still the mainWindow and in focus. I have tried the following code to force the main window and it doesn't wo...

how to manage multiple asynchronous NSURLConnection delegates?

I have a class that makes multiple asynchronous connections where each connection performs its own logic in the delegate methods. Because the delegate is the class itself, how can I implement this separation in logic in the NSURLConnection delegate methods? ...

Blur CALayer's Superlayer

Hi. I've got a CALayer and a sublayer in it. What i want to achieve is a blur of the superlayer (the area under the sublayer), just like the standard sheets do it. I've tried to set a .compositingFilter on the sublayer but this doesn't seem to work. Any ideas how to solve this? Code from the sublayers init: CIFilter *blur = [CIFilter...

Store selector as value in an NSDictionary

Is there a way to store a selector in an NSDictionary, without storing it as an NSString? ...

In Cocoa (or maybe GUI development in general) how do you specify an arbitrary number of things tiled together?

I'm new to creating GUI's, everything I've done up until this point is using the command line. I'm trying to create a port of minesweeper to the macintosh, as an experiment, and I've got the CLI working, but I'm running into walls everywhere with the gui. The first thing it seems I have to do, however, is be able to tile n x m 'boxes' f...

Looking for marg_setValue fix in iPhoneOS

I am trying to compile a library originally written for Cocoa. Things are good until it looks for the function marg_setValue(). It says there is a syntax error before char in marg_setValue(argumentList,argumentOffset,char,(char)lua_toboolean(state,luaArgument)); (it's talking about the third argument, not (char) ) I am trying to port...

What kinds of questions are Technical Support Incidents for?

Last year I received two "Technical Support Incidents" in the iPhone developer program, but when I went to renew I found that I would lose them. I have another two for this year, but I'm not really sure about the kind of problems that can be solved by using them. What kinds of questions are the best use of these Technical Support Incid...

Objective-C Plugin Architecture Security (Mac, not iPhone)

I'm possibly writing a plugin system for a Cocoa application (Mac, not iPhone). A common approach is the make each plugin a bundle, then inject the bundle into the main application. I'm concerned with the security implications of doing this, as the bundle will have complete access to the Objective-C runtime. I am especially concerned w...

How to convert an NSString to an unsigned int in Cocoa?

My application gets handed an NSString containing an unsigned int. NSString doesn't have an [myString unsignedIntegerValue]; method. I'd like to be able to take the value out of the string without mangling it, and then place it inside an NSNumber. I'm trying to do it like so: NSString *myUnsignedIntString = [self someMethodReturn...

How do I set the sender on a NSMenuItem's action?

The Apple documentation says that the sender passed to the NSMenuItem's action can be set to some custom object, but I can't seem to figure out how to do this. Is there a method I'm not seeing someplace in the documentation? ...

copying text from my cocoa application to another

Hi, I have a cocoa application, that on pressing a certain key gets selected text from the frontmost application and processes it. Now I'd like to replace the selection that it took with a processed text. How do I do it? TIA ...

Cocoa Launch agent registering itself after installation.

I have created Cocoa app which is type of launch agent. To distribute this I have created package as well which installs the app and copies the launchagnet plist file in /Libraries/LaunchAgents. Now the problem is after installation i want this app to be running in user context immediately without logoff/restart. If I register this with...

How do I enable spell checking within an NSTextField on Mac OS X?

I have an NSTextField that I would like to enable "as-you-type" spell checking. When I load my application I can do this from the Menu Bar > Edit > Spelling and Grammar > Check Spelling While Typing. I would like this option to be enabled by default. Within IB I can enable this for a NSTextView but I would like to use NSTextField for ...

Strange behaviour when posting CGEvent to PSN

EDIT - not getting much input on this so here's the skinny. I'm posting keyboard events to a PSN. I then switch to another window, post some more events (this time tat session level) and switch back to the first window. When I start posting to the PSN again, nothing happens. Until I move the mouse or scroll wheel. Why would this be ...

How do I catch global exceptions?

Is there a way to catch global "crashing" app exceptions like objc_exception_throw, EXC_ARITHMETIC etc. in code? I need that because I want to do some things before the app gets killed by the system. ...

Core Data: fetch an NSManagedObject by its properties

Hi guys, I have an object NetworkMember that has no attributes but is defined by its relationships Person, Network, Level and Role. In my app, I've found all the four relationships, but I want to make sure not to double-register my NetworkMember, thus I'd like to search for this NSManagedObject before instantiating it. How should I wri...

Common NSNotification mistakes?

A simplification... A building has an array of apartment objects. Each apartment has a single currentTenant. These tenants are of type Person. Note that currentTenant doesn't have a reference to the apartment, so can't send information back up the chain. When a tenant has a plumbing issue he raises an NSNotification: [nc postNotifi...

How do I dismiss an NSPanel when creating or opening a new document?

I am working on a document-based Cocoa application. At startup, the user is presented with a "welcome panel" (of type NSPanel) with buttons for common actions like "Create New Document" and "Open Existing Document". These actions are linked to the first responder's newDocument: and openDocument: actions, respectively, just like the match...