cocoa

Strategies for porting Carbon code to Cocoa

I'm looking for strategies and articles on making Carbon code 64-bit ready. Carbon for 64-bit does not and will not exist. It's pretty much a dead end. So in order to bring Carbon application and toolkits to 64-bit their GUI part will have to be re-written in Cocoa and Objective-C, right? How can I minimize the effort I have to put in...

NSBezierPath / Line Intersection / flatten

Hello, I'm currently porting my jruby/java2d Graph Drawing/Layouting application to macruby/cocoa. Therefore I need to get the intersection point of an open NSBezierPath with an closed NSBezierPath. In java2d I used the following trick. I flattened both paths and did a simple line intersection test for each segment. So is there a sim...

Suggested resources for learning about blocks in Snow Leopard

Now that there is no NDA, what are some good suggested resources for learning about blocks under Snow Leopard? ...

Dragging an Image from Safari and dropping it onto dock icon does not work in snow leopard?

I've got an app: You can drop an image file onto the app's dock icon and it will upload the image to a free image hoster. In 10.5 you could drag an image straight out of safari (and any other browser) and drop it onto the dock. (The app opened the image from the temporary folder the browser put it in and uploaded it to the net.) Now in...

Missing "find options" in Xcode 3.2

Generally speaking, I am very happy with the changes in Xcode 3.2. However, there is one thing which is driving me crazy: the "find in file" dialog has been jettisoned for the "find banner." But what is missing in this nifty little banner are the good-old options: starts-with, contains, whole-word, ignore-case, &c On my dev machine, th...

getting the path of a application at runtime + cocoa

Hi guys i want my application to run from removable storage devices and it should get the path of the removable storage it is running from or the rem storage device from which the app is launched. I have seen nsworkspace to get path of removable storage device but dont know how to get the path at run time. please suggest a way to do thi...

NSTableView responding to first click in a panel

I have noticed in the Interface Builder if I want to click on or drag from the Library panel, I only have to click on it once, even if the Library panel does not have the current focus. I am trying to build a panel that behaves similarly. Is there any simple way to let the NSTableView accept the click, even if the window does not have ...

NSServices not working

Hi, I've been trying to get NSServices working for my application recently with no success. I have set it up according to the documentation but it does not appear in the services menu ( however it does appear in the keyboard shortcuts section of the System Preferences as a service menu item) Anyway I set the service in my app controller...

Cocoa application architecture on Mac OS X

I'm getting back in to Cocoa development on the Mac after a long stint doing iPhone work. My previous experience with Cocoa on the Mac has just been dinky little tools. I'm looking to build something serious. Looking at a modern Cocoa application like iPhoto (or Mail or Things or....) many apps use the Single-Window, Source-List based a...

cocoa Document-based applications

I am building a simple document-based application in cocoa and I'm having problems to link common data between my document instances. I'd like to have some sort of AppController and have all my documents to access the same instance of this class. Instancing the object in document.xib will create different instances for each document. A...

Can I encode a subclass of NSManagedObject?

This is for an iPhone App, but I don't think that really matters. I need to send a custom object (which is managed by Core Data) over bluetooth using the iPhone's GameKit. Normally, I would just use an NSKeyedArchiver to package up the object as a data object and ship it over the line, then unarchive the object and I'm done. Of course, I...

Garbage collection of Core Foundation objects

Running the static analyzer on this piece of code: - (id) readForeignPref { CFPropertyListRef matchStyle = CFPreferencesCopyAppValue(CFSTR("PBXFindMatchStyle"), CFSTR("com.apple.Xcode")); return [(id)matchStyle autorelease]; } yields the following warning: Call to function 'CFPreferencesCopyAppValue' returns a Core Foundation ob...

IPhone - NSKeyedUnarchiver memory leak

I am using NSKeyedUnarchiver unarchiveObjectWithFile: to read in application data. When running with Leaks in Instruments, I am told that the following produces a leak: { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; ...

How to get the name or signature of the current method into an NSString?

Example: I have a method -myFooBarMethod:withFoo:bar:moreFoo: and inside the implementation of that method I want to dynamically get the name of it, like @"-myFooBarMethod:withFoo:bar:moreFoo: into an NSString. No hard-typing of the method signature. I feel that this has to do something with selectors. How could I get the name of the c...

How to find out who is the caller of a method or function?

I want to write a debug function or method that will help print useful information. When it is called, I need: the memory address of the calling object (if called by an object) the method signature of the caller (or the name of the method), or the name of the function the class name that owns that method or function Is it possible to...

How to create a macro with multiple lines of code?

I want to make a macro which will inject some code, like: if (foo) { [Bar fooBar]; } and then, where ever I need that, I put FOOBAR in the code. Not sure, but at compile time then the compiler replaces this with the actual code like in the example above. Maybe there's something different than a macro I could use for this? ...

get size of nswindow

Is there any way I get get the size of an NSWindow (in pixels) and display it? So when the person resizes the window the text will change and display the new size. ...

How to get rid of all this garbage in NSLog?

When I use NSLog(@"fooBar") it prints out a lot of stuff I don't want: 2009-09-03 13:46:34.531 MyApp[3703:20b] fooBar Is there a way to print something to the console without this big prefix? I want to draw a table and some other things in the console so that space is crucial... ...

resizing an NSPanel to fit a dynamic NSMatrix and a button

I have an NSMatrix that is filled dynamically with some form items. Now, I can conveniently call [theMatrix sizeToCells] and then pass it into the panel to be displayed. Now, I want the NSPanel object which contains this NSMatrix to resize to wrap nicely around it. The NSPanel also has a button at the bottom which should be under the ...

Application Delegate - Cocoa

Hey all, I want to incorporate an applicationDidFinishLaunching: into my cocoa delegate. How would I do this?? On the iphone SDK the applicationDidFinishLaunching is already in the application delegate, but when making my mac application I noticed that there were none. Best Regards, Kevin ...