cocoa

Making a layer structure for a drawing application

Hi, In relation to question an eralier question of mine, I have tried and failed to create a class with a NSMuttableArray member variable holding CALayerRefs. Can someone please guide me on how to do that. What I want to do is basically create CALayerRefs or CGLayerRefs or whatever, push them into my layers variable, and then, when I nee...

Cocoa NSImage full view question

I am trying to automatically load an image full screen after the application is launched but it looks just a little bit funky. The outside edge of the image view can be seen - how do I eliminate that? My code looks like this: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSImage *imageFromBundle = [NSIma...

How to read general user input in cocoa?

I am writing an app that automatically has an image load full screen immediately after the app is launched. When this happens, it seems that the only way for the user to get out of this full screen mode is to CMD-Q and quit the app. How can I set my own custom key stroke combination so the user can exit full screen mode and edit the ap...

Adding an NSProgressIndicator to the dock icon.

I'm creating an application which should show a progress bar in the dock icon. Currently I have this, but it's not working: NSProgressIndicator *progressIndicator = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0.0f, 0.0f, 10.0f, 20.0f)]; [progressIndicator setStyle:NSProgressIndicatorBarStyle]; [progressIndicator setIndet...

Saving Core Data database to sqlite file loses some recursive/circular relationship information

I have very simple circular (or self-reflecting) relationship core data model in my iPhone word game. Entity Word has one-to-many relationship to/with itself which points to related words: I use NSPersistentDocument Core Data Mac OS X template application to import words to Core Data sqlite database. After importing data I can see al...

Is there a way to assign multiple key equivalents to a Menu Item in Cocoa (via IB or programmatically)?

Specifically, I want my "New" menu item to respond to both Cmd+N and Cmd+T since it will open a new document in a tab.* How can I do this either in Interface Builder or programmatically? * I can explain the reasoning further if needed, but I'm hoping to avoid a discussion of the merits and rather focus on how to do it, not why to do it....

Accessing Button in NIB that is in my framework

Hello, I am trying to create a simple framework with a nib that has a button on it which can be customized (selector wise and title wise.) for this, i did the following: I added a property: @property (nonatomic,retain) NSButton*accessoryButton; and connected it to my outlet: @synthesize accessoryButton = littleButton; I then shar...

Cocoa: Correct way to get list of possible PlugIns directories for an app?

In a Cocoa app generally we can install a plugin bundle in one of a number of places. If for example the app is called "MyApp" you'd be able to install the plugin at: /Applications/MyApp.app/Contents/PlugIns ~/Library/Application Support/MyApp/PlugIns /Library/Application Support/MyApp/PlugIns /Network/Library/Application Support/MyAp...

Subclassing of NSMutableArray

Hi! In Cocoa Fundametals I found following code: @interface ValidatingArray : NSMutableArray { NSMutableArray *embeddedArray; } @end @implementation ValidatingArray - init { self = [super init]; if (self) { embeddedArray = [[NSMutableArray allocWithZone:[self zone]] init]; return self; } @end But I don't understand this l...

ivars when mixing C and Objective-C

I'm writing an Objective-C wrapper for a C library and having problems accessing the references of my ivars. The C library requires that I specify a function pointer that handles events, I specify it during the initialization of my Objective-C class. - (id) init { [super init]; RegisterClient( return self; } The C librar...

Using a Spotlight search result to open an application in a specific state

I have an application that will play a series of radio stations by choosing them from a drop down menu. Ideally I'd like to add some code, so that a spotlight search that would return any of the items in the dropdown and open the application as if you did this from within the application itself. The spotlight documentation gives no clue...

Brown noise on cocoa

Hi, How can I create a brown noise generator using Cocoa? BTW Brown noise is similar to pink and white noise and has nothing to do with "The brown note" or anything silly. See http://www.mediacollege.com/audio/noise/brown-noise.html ...

Execute IBAction on a custom event

How would I be able to run an IBAction based on another event? For example I could use a piece of code to run an IBAction. What I'm trying to do is have two different buttons run one or more IBActions. ...

Annoying Bump Sound with Keyboard Events in NSOpenGLView subclass

I've overridden an NSOpenGLView to handle keyboard events. The event detection is working fine, but every time I press a key I hear and annoying bump sound. How can I tell my view to chill out? Here's what my keyUp: method looks like: -(void) keyUp:(NSEvent *)theEvent { NSString *characters = [theEvent charactersIgnoringModifiers...

How do I override initWithContentRect in MacRuby?

I want to override initWithContentRect on a subclassed NSWindow, as I've seen done in Obj-C, in order to create a borderless window from a nib. If I try this: class GroupWindow < NSWindow def initWithContentRect(contentRect, styleMask:windowStyle, backing:bufferingType, defer:deferCreation) super.initWithContentRect( conten...

Convert NSPoint in screen coordinates to window coordinates

I am implementing drag and drop in a cocoa application and I am using the following method from the NSDraggingSource Protocol: - (void)draggedImage:(NSImage *)draggedImage movedTo:(NSPoint)screenPoint{ The NSPoint is given in screen coordinates and I need it in window or view coordinates. If the method was called with an NSEvent I cou...

Creating a custom capture window in Cocoa

Hi, I am trying to make a custom transparent bordered window(without tittle bar) to capture a part of the screen.This window should be resizeable from the bottom right corner area,and could be moved by dragging any of the border lines.This window should be such that, it could also be moved over the apple menu. I am very new to Cocoa, C...

Converting CVImageBufferRef to PNG

Hi, I want to write all frames to disk using QTKit.framework for camera input. But all the images I get are half transparent and without some colors, maybe colorspace problem? ;( They seem good in the preview View but when I write them "something" happens. I wonder what it that. -(void)savePNGImage:(CGImageRef)imageRef path:(NSString *)...

How to securely include secret key/signature in iOS/Cocoa apps

I want to include a secret key into an iOS app so that the app can "prove" to a certain server that a request is coming from the app itself and not some other system. I know that simply hardcoding a secret key into the code itself is very vulnerable as anyone can jailbreak their phone and attach GDB to my app's process to get the key. ...

How to change an NSTableView's selection without using deprecated methods

I have the Apress "Learn Cocoa" book (published in 2010 BTW) and I am getting a deprecation error on one of the lines. The code is: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { self.villain = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Lex Luthor", kName, @"Smallville", kLastKnownLocation, [NSDa...