cocoa

pthread vs NSThread: which is faster

In Cocoa, is NSThread faster than pthread? is are any performance gain? is it negligible to ignore? ...

Removing all CALayer's sublayers

Hi. I have trouble with deleting all layer's sublayers. I do this manually, but it's unwanted code clutter. I found many topics about this in google, but no answer. I tried to do something like this: for(CALayer *layer in rootLayer.sublayers) { [layer removeFromSublayer]; } but it didn't work. Also, i tried to clone rootLayer....

Can't populate NSMenu from document controller

Hi all, I've a MainMenu.xib and a MyDocument.xib. I need to dynamically populate some NSMenuItem's from my document controller but I'm at a loss on how to get to it from MainMenu.xib. I've tried adding an NSObject to MainMenu.xib and make it an instance of my document controller but I can't populate the NSMenuItem's from the NSArrayCon...

cocoa iphone core-data predicate one-to-many fetchrequest

I have a set of data where one of the attributes (Firmware) is a one-to-many relationship. If I want to get any records where the firmware id is 1 I can create a predicate using @"(ANY Firmware.FID==1)" Then I have another set of conditions that will refine the set even more using (TopLevel==YES) AND (Parent>0) How can I combine t...

Getting the string value from a NSArray

I have a NSArrayController and I when I get the selectedObjects and create a NSString with the value of valueForKey:@"Name" it returns ( "This is still a work in progress " ) and all I want to have is the text in the "" how would I get that? also, this my code: NSArray *arrayWithSelectedObjects = [[NSArray alloc] initWithArray:[...

Why does cocoa use delegates rather than inheritance?

Why does cocoa use delegates rather than inheritance? ...

Deleting a object NSArrayController

I have a NSTableView which gets it's data from a NSArrayController and I need to delete the currently selected row, I know NSManagedObjectContext has a delete deleteObject: method but I can't think of how to deleted it from the NSArrayController? ...

Am I updating my NSArray that's bound to an NSTableView right?

I have a pretty standard setup where I have an array in my controller that I'm binding to an NSTableView. When I add an object to this array with the UI, I add elements by copying the array to a mutable array, adding the contents, then copying it back. I saw this idiom somewhere, but I'm not really sure where, or whether this is actually...

NSArrayController and KVO

What do I need to do to update a tableView bound to an NSArrayController when a method is called that updates the underlying array? An example might clarify this. When my application launches, it creates a SubwayTrain. When SubwayTrain is initialised, it creates a single SubwayCar. SubwayCar has a mutable array 'passengers'. When a ...

False Applescript result in Cocoa

Hi, I have 3 tracks in iTunes and run this procedure: -(IBAction)reloadButtonClick:(id)sender; { NSAppleScript *script ; NSString *source ; NSString *result; NSDictionary *errorDic ; NSAppleEventDescriptor *ed; int total; source= @"tell application \"iTunes\" to get cou...

Querying a 'column' in core data

I have a core data entity named "Folder". Each "Folder" has a 1-to-many relationship with the entity "File", and each file contains the field "filename". What is a succinct way of producing an array of all of the filenames for a given folder? I expected it to be something like: NSManagedObject* folder = [self getSomeFolder]; NSArray*...

How is NSCell displayed?

An NSControl's cell isn't in the view hierarchy. Am I correct? If it isn't, how is it being drawn on the view if it's not in the view hierarchy? I ask because I want to have a View/Control subclass that I can drag out onto a contentview, then add buttons into that view, and have the lowest component be the cell. So the cell can get all...

Cocoa and Objective-C++

Hey guys! I think I understand how Objective-C++ works in relation to Cocoa, and I am fairly versed in the basics of command-line C++ but sort of afraid to try mixing it with Objective-C. I can create a GUI with Interface Builder in Xcode, and even make classes (.h and .m files) for the interface automatically. The outlets, maybe action...

how to get a window to receive drag and drop files in Xcode

i am trying to get drag and drop working in xcode 3.1.4 on osx/leopard. any pointers or hints or maybe even example code? i cannot find anything out there and it is really disappointing. i want to have the interface respond if files are dragged on the main window. ...

NSArrayController "Content set" bound to NSTreeController issue

I have an NSOutlineView bound to a NSTreeController and a CoreData Datamodel. NSOutlineView displays his data properly. A NSTableView's cell values bound to a NSArrayController, displaying data from CoreData. NSTableview displays his data properly too. The Datamodel has a relationship between data for NSOutlineView and NSTableView W...

Is there a way to get/use the OS X 10.3 Cocoa SDK on a 10.6 machine?

Before you ask, yes, I have a very good reason for wanting something to run on 10.3. It's a very small in-house project that must run on a very important person's machine, which cannot be upgraded for a very good reason. =) The 10.6 DVD doesn't seem to offer an option to install the 10.3 SDK, only 10.4+. I also can't seem to find it on ...

Showing Random Words From Plist Dictionary - Memory Leak?

Hi. I am new to iphone development. I am "old School" - I was tought to use Procedures etc. when programming. Everything is object oriented these days but my style is still as its always been. Please bear that in mind. My project is tiny and really just a proof of concept. The program below works on a timer - every 30 seconds it will r...

Cocoa OpenGL Texture Creation

Hello, I am working on my first OpenGL application using Cocoa (I have used OpenGL ES on the iPhone) and I am having trouble loading a texture from an image file. Here is my texture loading code: @interface MyOpenGLView : NSOpenGLView { GLenum texFormat[ 1 ]; // Format of texture (GL_RGB, GL_RGBA) NSSize texSize[ 1 ]; // Width a...

return a copy or a mutable object

Which variant is more correctly? //first variant - (NSArray*) someArray { NSMutableArray* mutArr = [[NSMutableArray alloc] init]; //...some operations with mutArr NSArray* retArray = [mutArr copy]; [mutArr release]; //remove mutArr return [retArray autorelease]; } //second variant - (NSArra...

How can I change the audio output device in Objective-C?

I'm building a simple Cocoa app and I want to direct the audio output to a specific device, instead of the system selected one. I know some apps, like Skype, let you select where to send the output to. How do they do this? I tried the MTCoreAudio framework but I can't even compile my app (or their AudioMonitor demo) with it included and...