cocoa

Using the Apple Scripting bridge with Mail to send an attachment causes the message background to go black.

Hello, When I use the Apple Scripting Bridge to send a message with an attachment the background of the message is set to black which is a problem because the text is also black. The code in question is: MailApplication *mail = [SBApplication applicationWithBundleIdentifier:@"com.apple.Mail"]; /* create a new outgoing message object ...

How to get the last key pressed on Mac ?

Hi All, 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...

Cocoa memory management - object going nil on me

Hi all, Mac OS X 10.6, Cocoa project, with retain/release gc I've got a function which: iterates over a specific directory, scans it for subfolders (included nested ones), builds an NSMutableArray of strings (one string per found subfolder path), and returns that array. e.g. (error handling removed for brevity). NSMutableArray * ...

File permission

Hi , Im using Package Maker for my installer. Everything work fine and my appln launches as expected. But during a process where user need to fetch a data from the server and write it in a file which is already created shows write permission error. Can anybody help me to set the file permission so that i will allow my appln to write c...

Cocoa: how to connect a button to a view?

Hello, The title question might be a little vague. I will try to explain as good as i can (also note im new to cocoa programming so excuse any mistakes :) ). I have a VIEW that extends NSView where i would like to draw some images. I want the images to be loaded from some files on the disk, when i click a button. I managed to do all t...

Core Data, managed object context, NSArrayController.. straighten me out a bit

So I've got an .xcdatamodel with about a dozen Entities defined and related to each other, with attributes and so on. So far I've been trying this in to a GUI using NSTableViews to display/enter data, and NSArrayControllers that I instantiate for each entity. This is all working great. They all tie in to the App Delegate's Managed Ob...

Daemon running as user nobody needs to copy file from Desktop

I have a daemon that is running as user nobody. It needs to copy a file that I specify into /Users/Shared/MyFolder If I tell it to copy a file that is already in /Users/Shared/ it works fine. If I tell it to copy it from somewhere in my home directory like the desktop, the copy fails. I'm using NSFileManager copyPath:toPath: Any ideas? ...

Cocoa button won't display image

Just started exploring Cocoa so pretty much a total noob. I've written a very simple game. Set it up in Interface Builder and got it working fine. It contains a number of buttons and I'm now trying to get the buttons to display images. To start with I'm trying to get an image displayed on just one of the buttons which is called tile0 ...

Saving user credentials securely in a Cocoa application

Need to store some valuable data securely on Mac and access it with my application. How to? ...

writing RAW files with Core Graphics

Gentelmen, is there is any possibility to write photos in RAW format? I especially interested in com.cannon.cr2-raw-image UTI type. CGImageDestinationCreateWithData returns <Error>: CGImageDestinationCreate type doesn't support writing for given UTI. Can i install some additional codecs? May be some special library, even not CoreG...

performKeyEquivalent on active application

In carbon/cocoa, is it possible to send something like performKeyEquivalent to the current key window? I want to send a key event to whatever application the user has active. Thanks! ...

Switching textstorage of NSTextViews back and forth

I'm trying to make a feature in a product which gives the user the ability to split a textview into two. The way this is done is by removing the textview from it's superview, making a NSSplitView and adding the textview as well as a new NSTextView instance to this splitview. Lastly I make these two textviews share the same textstorage in...

How to edit subviews of a custom cocoa plugin

If you add a custom view to a xib, then add a textfield, you can select the textfield and edit properties. If I create a custom view as a plugin and it has a textfield as a child view, how do I edit the values of the textfield at design time when using the plugin? ...

Using the Cocoa framework, when setting a label, an explicit cast to NSString works but stringValue raises an exception. Why?

I'm setting a UILabel to a value stored in as a NSNumber. If I do this foo.label.text = [bar stringValue]; then I get a NSInvalidArgumentException However if I cast by doing: foo.label.text = (NSString *)bar; then things work ok. Can anyone explain why this could be the case? ...

Declaring two classes that contain instance variables of each others' types.

Let’s say you wish to have two classes like so, each declaring an instance variable that is of the other’s class. @interface A : NSObject { B *something; } @end @interface B : NSObject { A *something; } @end It seems to be impossible to declare these classes with these instance variables. In order for A to include an IV o...

How to chop off file:// from NSURL

I have an NSURL. It is file://localhost/Users/Me/File.xml I want an NSString that is /Users/Me/File.xml Is there some nice function I can use to do this? ...

Can I mix OpenglES with standard Cocoa widgets on an iPhone app?

In case this is possible, it would be nice to see some examples! Thanks, rui ...

Add NSView from different nib

How can I add a subview when the new view is in a different xib file? The class for the different nib is an NSViewController and I'm using self = [super initWithNibName:@"NewView" bundle:nil]; to load the nib Can I just do something like: NewView *nv = [NewView new]; [oldView removeFromSuperView]; [mv addSubview:[nv theView]]; or do...

What is the difference between moveBackward: and moveLeft: when using NSResponder -interpretKeyEvents:?

I'm implementing a custom text box using -interpretKeyEvents: and am trying to figure out what the difference is between moveBackward: vs moveLeft: and moveForward: vs moveRight:. moveLeft: is bound to the left arrow and moveBackward: is bound to Ctrl + B. The documentation describes them almost identically and they seem to behave identi...

NSString simple pattern matching

Hi all, Mac OS 10.6, Cocoa project, 10.4 compatibility required. (Please note: my knowledge of regex is quite slight) I need to parse NSStrings, for matching cases where the string contains an embedded tag, where the tag format is: [xxxx] Where xxxx are random characters. e.g. "The quick brown [foxy] fox likes sox". In the ab...