cocoa

Localizing Application (main) Menu?

I'm porting a UNIX application which uses the Qt framework (Qt, not QuickTime) to Mac/Cocoa. Life is good, generally. Qt has a Cocoa implementation, so with some Objective-C++, I've gotten lots of Mac-specific bits working. I can't get the main menu (i.e., the Application menu) to translate. It's set using: [NSApp setMainMenu:menu]...

For Iphone how to reference root view controller from currently loaded view, so view can be replaced/switched

I'm trying to switch a currently loaded view with a new one. I have 3 xib files and 3 sets of ViewControllerFiles. RootViewController loads correctly, and correctly loads HomeViewController. The line that errors currently is this [self.rootViewController.view insertSubview:gameController.view atIndex:1]; error: request for member 'v...

XCode>Instruments>Leaks - Where is "gather leaked memory contents" data?

When you check gather leaked memory contents in the Leaks instrument what does this do? I have a troublesome leak and thought maybe this "memory content" might be useful in tracking it down...but I can't find it!?! ...

Memory leak in loadNibNamed?

I'm about to wrap up my first iPhone app and figured I'd run it through the Leaks Performance Tool. After fixing one obvious one, the only one I have left is one with a Nib acting as a table header view loaded through loadNibNamed (I was following the Recipes demo here). - (void)viewDidLoad { [super viewDidLoad]; if (self.tab...

Printing a file to NSImage not working right (cocoa)

This is probably a n00b question so I apologize in advance. I'm working with NSImage for the first time and basically I need to simply take a picture that is in my Resources folder, and have it display in an NSView/NSImageWell when a button is clicked. NSImage *image = [[NSImage alloc] initWithContentsOfFile:@"tiles.PNG"]; if ( [ima...

NSOperationQueue and concurrent vs non-concurrent

I want to setup a serialized task queue using NSOperationQueue but I'm a little confused by the terminology discussed in the documentation. In the context of an NSOperation object, the terms concurrent and non-concurrent do not necessarily refer to the side-by-side execution of threads. Instead, a non-concurrent operation i...

Quick way to find what thread asserted in gdb?

When my Cocoa app hits an assertion in the code, gdb gives me a prompt as expected, but it's never (ok, rarely) in the right thread. I know I can use Xcode's GUI debugger and it makes it a little less painful, but I'm thinking there has to be a gdb command line trick I don't know. Is there an easier way of finding the thread that asse...

Use of retain in initWithCoder?

I am reading up about Encoding and Decoding and I noticed that sometimes people miss the retain off the end, I have also noticed that retain is sometimes used on some varables but not others. Can I ask ... (1) What is the purpose of this retain and why is it sometimes not needed? (2) Does the use of the retain imply that I need to matc...

NSKeyedArchiver write XML (or other human readable)?

I have been trying to get the NSKeyedArchiver to write out my data in a human readable form (i.e. not as a binary file) I understand that I can use ... setOutputFormat: NSPropertyListXMLFormat_v1_0 But ... I just can't seem to get the syntax right, can anyone point me in the right direction? NSData *artistData; NSLog(@"(*) - Save Al...

Core Data: migrating entities with self-referential properties

My Core Data model contains an entity, Shape, that has two self-referential relationships, which means four properties. One pair is a one-to-many relationship (Shape.containedBy <->> Shape.contains) and the another is a many-to-many relationship (Shape.nextShapes <<->> Shape.previousShapes). It all works perfectly in the application, so ...

In Cocoa, do you have to do anything special to make sure you copy resource forks when copying files?

I had assume I could just do this, but I don't have a way to check that resource forks went along for the ride. NSFileManager *fm = [NSFileManager defaultManager]; [fm copyPath:absSourcePath toPath:absDestinationPath handler:err]; edit: I need to copy in a 10.4-6 compatible manner. (Yes, really 10.4.) ...

Check existence of file on disk?

Currently I am loading data from a previous session into my application using the code below. To guard against there being no previous data I am using a temp variable to check the return value before making my assignment. I am just posting here as this feels a bit clunky, is there a way to check a file exists on disk so I can check befor...

Finding a word's frame (position and size) on the screen using Cocoa or Carbon

Here's a tough one: I need to be able to find a word's position and size (its frame) on the screen (its first occurence is enough, from there I should be able to get the next ones). For example, I would like to be able to detect word positions in (but not limited to) Word, Excel and PowerPoint for Mac, as well as Safari and others. Th...

isEqualToString can the items be swapped?

I am just curious if there is a way to swap the two stings in this example? // This works for(eachArtist in artistCollection) { if([objFirName isEqualToString: [eachArtist firName]]) NSLog(@"DELETE ...."); } What I was trying to do was (see below) can this be done or is the above the only way? [eachArtist firName isEqualToString: obj...

Warning Pass-by-Value?

I am fairly new to Objective-C and whilst running the Clang static analyser this section of code gave me the following error warning: Pass-by-value argument in message expression is undefined [artistCollection removeObject:removeArtist]; Can anyone cast any light on this warning for me? case 6: NSLog(@"(*) - First Name:"); sc...

Document Based App with Core Data vs plain Core Data app?

I am trying to understand the key differences between these two types of Core Data application templates. My understanding is that with a document based core data app you get access to NSDocument instances and a lot of document based behaviors for free (save dialogs, undo, etc). Assuming I want to create an application that is more "Pr...

Invalid memory access of location with Rococoa

I've been trying to code a simple screenshot application using rococoa (java to osx cocoa api library), and managed to get as far as actually taking the screenshot, and then saving it to a file. Unfortunately, once in a while, the application fails with an 'Invalid memory access of location...' error. I'm assuming this is due to somethin...

Differences between NSTableView and NSCollectionView

I'm trying to decide which path to take for developing my Snow Leopard app. First, I should preface with the obvious differences: NSTableView can have multiple columns of data for representing different parts of the same "element" of data (a row) where NSCollectionView can display a grid of data as well, but every row+column combo is it...

Can a category simultaneously implement a protocol?

If a category I'm creating for a class adds methods that also fulfill the contract set out by a protocol, I'd like to flag that category class as implementing the protocol, and thereby indicate to the Obj-C pre-processor that the class effectively implements the protocol as well. Example delegate (for clarity, thanks Ole!): @protocol S...

Hidden Features of Interface Builder?

What are some uncommon or "hidden" features of Interface Builder you wish you would have known about when first learning Xcode + Interface Builder? Edit: Xcode specific tips here. This question is specifically concerned with the GUI and not so obvious features of Interface Builder. And only tangentially related to Xcode. ...