cocoa

How to print a float value nicely?

Example: I have a float value like 1294322.0000000, and I want to print it out in a label, like that: 1.294.322 So at every thousands-position one point inbetween. I bet you know what I mean. Don't know the exact english words for that. Or, for example, I have a float like that: 15.29, then it should look like "15,29". Or a float li...

Getting NSOutlineView rows to be editable

Hi, Does anyone here know how to make cells in NSOutlineView's editible? Im using the sampe code from apple and I cant seem to get it work at all. I am trying to set it up so that when you click twice in rapid succession on a cell in the NSOutlineView, the cell becomes editible so the user can update the text inside the cell. (In the sa...

Deleting non-empty folders and specific file types.

What is the best way to remove a folder, deleting all subfolders and files? What is the best way to remove files with a specific extension; e.g., if I want to remove only files with '.txt' extension? Cocoa or carbon. ...

Hide buttons from titlebar in Cocoa

Hi all! Let's see, Apples Human Interface Guidelines say: How do I make the very first titlebar in that image (with only a close-button). Disabling both 'Resize' and 'Minimize' in IB only make the resize/minimize buttons get disabled. But I want them to dissapear. How can I do that? Thanks in advance. ...

MVC Specification

Of all MVC-capable GUI toolkits, which one do you think has the best spefication and which one the most drawbacks ? In which one do you find your code easy to maintain and extend? Which is one do you find crippled (if any) and for what reasons ? I' m mainly interested in Qt and Cocoa but i would like to hear about others too. Thank you...

Is performance affected by adding categories to a class.

I'm new to Cocoa and have a small question before I get carried away with using categories. Say you add a new method to NSString. Does that affect performance of normal NSString messages, or are category methods only checked when a method call does not match the standard method set? ...

Why do AppleScript "tell" commands run a non-GUI instance of my GUI application in the background?

I'm writing a standard Cocoa application, and I've just started implementing AppleScript support for it. I've defined and implemented a property called testprop for my top-level application scripting class, and accessing it works just fine: if I launch an instance of my app and run the following AppleScript in Script Editor, I get the ou...

Accessing NSString properties of a Core Data entity

I'm moving my initial steps in the Core Data realm (and I'm quite new to iPhone development, too) and I found a behavior I cannot explain. I declared a subclass of a NSManagedObject and defined a few properties, some of them of type NSString *, MyObject.h is something like: @interface MyObject : NSManagedObject { } @property (nonatomi...

NSpoint from NSTextView insertion point

I have an NSTextView and require the coordinates of the insertion point to display a view there upon user interaction. There is a function to get the character index from an NSPoint. I am wondering if there is any easy way to do the opposite? Thanks for any help! ...

How do I execute code on Application startup in a Document-based app

I have a Cocoa document-based application. When the app launches, I want it to execute some code, which will create a dictionary that I need to be accessible to any document in the application, but I only want the dictionary created when I start the app, not when a new document is opened. Currently I have one controller class, which is ...

NSFileHandle readInBackgroundAndNotify does not work

Hi I'm using NSFileHandle's readInBackgroundAndNotify method to get notifications when a log file has been updated. I have the following code: - (void)startReading { NSString *logPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Logs/MyTestApp.log"]; NSFileHandle *fh = [NSFileHandle fileHandleForReadingAtPath:logP...

What is the Cocoa equivalent of UpdateSystemActivity?

I'm converting a Carbon app to a Cocoa app and I can't find the Cocoa equivalent for: UpdateSystemActivity(UsrActivity); Any Mac people out there care to point me in the right direction? Thanks. UPDATE: I'm building 64bit. Building 32bit works fine, but I get symbol not declared in this scope errors for UpdateSystemActivity (and ot...

How best to debug a crash within objc_msgSend?

I have a crash taking place when an NSAutoreleasePool drains. Presumably the pool is trying to deallocate an object that has been prematurely released by another piece of code. The crash I have is in the midst of objc_msgSend as it is trying to send a message to an object that doesn't exist anymore. Given the stack state, what tips/tric...

Is there a simple way to combine a text and icon in an NSCell in Cocoa?

Hi, I'm trying to create a very simple selection list widget based on NSOutlineView. However, I'm having a hard time figuring out how to display an icon and a label right next to it, which is really the expected behavior in all the mainstream implementations of that kind of widget out there (iTunes, mail, Finder,...). So far I am just ...

CoreData: Checking for Null

I have a CoreData entity (waypoint) with a foreign key to another entity (track). When the foreign key is set, or if it is not set, this if statement works fine: if ([wp track]) { thirdLabel.text = [NSString stringWithFormat:@"Part of Track: %@", [[wp track] title]]; } However, if the track that the waypoint is keyed to has been del...

Current Text Direction (BiDi support) in Cocoa?

Hello! I recently received an Arabic translation for my app, but would like to do more than simply replace the strings. I can re-layout most of the NIBs with Interface builder, but there are a few things that I need to do programmatically. Is there some way in Cocoa to figure out if the current locale is a RightToLeft locale, or do I...

How to get Custom meta data which is already set?

I use XMPkit to write custom meta data for any kind of images. the source is as shown below: -(IBAction)AddKeyword:(id)sender { SXMPMeta::Initialize(); SXMPFiles::Initialize(); string actualPrefix; SXMPMeta::RegisterNamespace(kXMP_NS_SDK_EDIT, "xsdkEdit", &actualPrefix); SXMPMeta::RegisterNamespace(kXMP_NS_SDK_USERS, "xsdkUser",&actua...

How to keep the last tree item of NSOutlineView in the most bottom of a Sidebar?

I'd like to have the same behavior of special items as it's done in the Things application. I mean Logbook and Trash items in the bottom part of the Sidebar: Please advise any way to implement the same functionality in the sidebar tree. I feel that special ‘spacer’ tree item should be used together with outlineView:heightOfRowByItem:...

Get current playing song using Cocoa

Hi all! Is there a way (ofcourse there is a way, but which way) to get info about the song currently playing in iTunes on a Mac (OS 10.5.8 and OS 10.6) programmatically? I need this for my Cocoa application. I use iTunes 8 and Objective-C. Thanks in advance. ...

Capturing all methods/message calls on an object

How do I put a "hook" on an object so I can see what messages are being sent to it? (ie do an NSLog() every time a message is sent to an object). I think recall seeing this done before but I forget how. I am thinking it might help me track down why part of my code is not working. ...