cocoa

getting string bound cocoa

Hi, I have an NSString object having string content as "Abc". It has font name, type and size as "Arial", "Bold" and "12.0" respectively. How can i know the bounding rect of the the said string. ...

Right way to make controller react on space key event

Im making an application where i got a cue list, and some other views around it. When the user presses Space, i want the next cue to play. No matter what view is first responder, unless its a textfield. So even though another table is selected, i want the cue to get played. I have made a custom class that acts as cue controller, this i...

How to prevent/deal with a crash when playing a corrupt MP3 with NSSound

Hello, As my program allows the user to import any .mp3 file into their library, there is a possibility that they might try to play an mp3 that is in someway corrupt. My audio player uses NSSound to play the file and currently when presented with a dodgy mp3 file it crashes with an EXC_ARITHMETIC exception. A brief look on this site tol...

NSMenuDelegate questions

I have an NSMenu which contains both static and dynamically created NSMenuItem's (static meaning NSMenuItem's created in Interface Builder, dynamic meaning NSMenuItem's created at run-time). Although I'm developing on 10.6, my application also offers 10.5 support. My menu consists of a number of dynamic NSMenuItem's which contain subme...

Getting a CGImageRef out of a PDFDocument.

I have a PDFDocument (made up of PDFPages ofcourse) and I need a CGImageRef to stick into my IKImageView. Currently, I get the datarepresentation from the PDFPage, put it into an NSImage, then get the TIFFRepresentation of the NSImage, put it into a CGImageSource, and then get the CGImage out of the source. That seemsneedlessly complic...

Populating NSTableview from a mutable array.

Hi, I've been attempting this for two days, and constantly running into dead ends. I've been through Aaron Hillegass's Cocoa Programming for MAC OS X, and done all the relevant exercises dealing with NSTableview and mutable arrays, and I have been attempting to modify them to suit my needs. However none of them seem to be using an ar...

NSFetchedResultsController and NSFetchRequest

Hello, When I assign an NSFetchRequest to an NSFetchedResultsController instance and then try to use that same NSFetchRequest for a small query to the managedobjectcontext I get a memory bad access. Does that mean that every instance of NSFetchRequest can only be used once? Thanks! ...

Overlay for 3rd party application

Hi, I'm looking for a way to display an overlay (hud) for a third party application on MacOSX. It should look like this. My working steps would be: find window by title get resolution of window create own invisible window check for moving events of target window I'm not very familiar with MacOS programming with Carbon and Cocoa and...

Data modeling in CoreData, (folders and documents with many children, etc)

Hi, I have used CoreData a couple of times but data modeling was very simple. This time I am supposed to implement the following: User can create documents and folders (they don't have to be real folders/directories). Folders can contain documents or other folders Documents have: 1 Title, 1 Description and 8 children Each child a...

"Tab" between controls without tab key

I have a window which happily tabs between its controls using the tab and and shift-tab keys. However, I also want to be able to move between controls with the up and down arrow keys (in this case). How can this be achieved? ...

How to have a plugin import UTI types

I'm working on a video sharing application that can load plugins that share to different places (Youtube, Twitvid, Facebook, etc.) I have a plugin that reads in a custom file type. We'll call it a .foo file with some information about the video being shared. So I put this foo UTI type in the imported UTI type section of the plugin bundle...

How to steal audio from specific application?

Hello, I am trying to figure out how to capture the audio from a given software running on a mac, just like audio hijack does. I'm aware that this is not the first question on the subject, but I'd like to better understand the possibilities on how to do it. Crete a user space driver is the only solution to achieve it? ...

Enabling offline application storage in webkit based cocoa app

What is required to enable offline web app caching for apps using the WebKit class to load web pages? Right now, if I attempt to load the app cache like so: cache = window.applicationCache I get: DOMApplicationCache oncached: null onchecking: null ondownloading: null onerror: null onnoupdate: null onobsolete: null onprogress: null...

What could be causing all these Objective-C build errors

moveMe[639] <Error>: CGContextSaveGState: invalid context moveMe[639] <Error>: CGContextSetBlendMode: invalid context moveMe[639] <Error>: CGContextSetAlpha: invalid context moveMe[639] <Error>: CGContextTranslateCTM: invalid context moveMe[639] <Error>: CGContextScaleCTM: invalid context moveMe[639] <Error>: CGContextDrawImage: invalid ...

Whats more efficent Core Data Fetch or manipulate/create arrays?

I have a core data application and I would like to get results from the db, based on certain parameters. For example if I want to grab only the events that occured in the last week, and the events that occured in the last month. Is it better to do a fetch for the whole entity and then work with that result array, to create arrays out of...

CGImageGetWidth returns different size then actual image

Hi i have a lot of image reading in my app and when I load the files i use CGImageGetWidth and CGImageGetHeight to get the sizes of the images. However this does not seem to return the right values all the time. For example if I have an image whose size is 114x14, these functions will return 126x22 or something random like that. The r...

Sort an NSArray in Descending Order

Hey guys, I have an NSArray of NSNumber objects that I have successfully sorted in ascending order using the following: [myArray sortedArrayUsingSelector:@selector(compare:)] However, I need to sort this in descending order. I take it that compare: only sorts in ascending order. While I can go about reversing the NSArray, I am curious...

count elements inside id<NSFastEnumeration>

I have an id<NSFastEnumeration> object. I want to count the elements inside the object. How can that be achieved? The only method NSFastEnumeration implements is: - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len This method returns the count I am looking for, but a...

Simple Sockets in Objective-C

Hey guys, I've had trouble finding simple guides/examples for basic sockets in Objective-C (using NSSocketPort with NSFileHandle or using CFSocket/CSNetwork). Can anyone recommend a guide or a useful example? I would appreciate this greatly! I have tried to use this, but it is incomplete. Thanks! P.S. I have been stuck in this part of ...

Cocoa: Custom control not limited to window frame - how to start?

Hello! I want to build a custom control that would work like this: You have a kind of NSButton with an image. You click the button and than appears a big square with a grid of photos. You click one of the photos and it is set up as new image for the button. (square dissapears) Now, how to draw this big square with photos if I want it n...