cocoa

What is the best way to redirect stdout to NSTextView in Cocoa?

Hi: I want to redirect stdout to a NSTextView. Could this also work with outputs of subprocesses? What might be the best way to achieve this? EDIT: According to Peter Hosey answer I implemented the following. But I do not get a notification. What am I doing wrong? NSPipe *pipe = [NSPipe pipe]; NSFileHandle *pipeHandle = [pipe f...

How to get attributes from an element in XML

I have constructed an XML tree structure of an XML file. I am able to trace the entire tree. When i want to retrieve the attributes of an element, it is returning as NSXMlNode of kind NSXMLAttributeKind. How can i extract the key value pairs in the attribute node. ...

String formatting in cocoa

Hi I am trying to send some text in an email from my cocoa app (by using Mail.app). Initially I tried using HTML to send properly formatted text. But the mailto: URL does not support html tags (even after setting headers) So I decided to use formatted string (left-aligning of string) This is what I have in my mailto: link's body argume...

Cocoa: Plugin Cannot Open App Window

Hi. I am developing an plugin for OsiriX. In that app i have 3-4 nib files. Also in for plugin there are files (.h & .m) called PluginFilter where method called - (long) filterImage:(NSString) menuName is present from which the plugin start execution. Now my problem is that, I have return the code to launch main window is in some o...

Help with stock ticker style scrolling using Core Animation

Hi, I'm looking for some guidance on the best way to implement stock ticker style right-to-left scrolling of CALayers in Core Animation on OSX. I'm pretty new to Cocoa and don't know the best way to implement this. I have a continuous stream of news items and stock details that I turn into CALayers (made up of 1 image and a CATextLayer...

Differing NSNumberFormatter behavior

Consider this code: NSNumberFormatter *nf = [[NSNumberFormatter alloc] init]; nf.numberStyle = NSNumberFormatterCurrencyStyle; NSLocale *l = [[NSLocale alloc] initWithLocaleIdentifier:@"it_IT"]; nf.locale = l; [l release]; nf.decimalSeparator = @","; nf.currencySymbol = @"US$"; [nf setLenient:YES]; NSString *s = @"US$ 0,05"; double d =...

How do I set the font size in a text cell so that the string fills the cell's rect?

I have a view that contains two NSTextFieldCells. The size at which these cells are drawn is derived from the size of the view, and I want the text in each cell to be the largest that will fit in the derived size of the cell. Here's what I have, which doesn't set the font size: - (void)drawRect:(NSRect)dirtyRect { /* * Observan...

CoreData INSERT or REPLACE ?

Hello, I'am currently migrating an iphone application using SQLite to CoreData. I need to do an INSERT or REPLACE to add only the new content, is there a way to do this or do I have to fetch all the DB and look for existing objects and add the new ones ? Thanks. ...

Apple Singleton example query?

I am a little confused by this snippet of code (presented in the CocoaFundamentals guide) that overrides some of the methods when creating a singleton instance. static id sharedReactor = nil; +(id)sharedInstance { if(sharedReactor == nil) sharedReactor = [[super allocWithZone:NULL] init]; return sharedReactor; } . +(id)alloc...

Singleton: Where to create instance?

Does anyone have any preferences or comments about using either ... static id sharedReactor = nil; +(id)sharedInstance { if(sharedReactor == nil) sharedReactor = [[super allocWithZone:NULL] init]; return sharedReactor; } OR: static id sharedReactor = nil; +(void)initialize { if(sharedRandomReactor == nil) { sharedRandomReactor = [[...

Cocoa Memory Management NSArray with Objects

Hi, I'm having troubles releasing objects.. To explain it better I have included my code below. NSTask *task = [NSTask new]; NSTask *grep = [NSTask new]; NSPipe *pipe = [NSPipe new]; [task setStandardError: pipe]; [grep setStandardInput: pipe]; [pipe release]; pipe = [NSPipe new]; [grep setStandardOutput: pipe]; [task launch]; [grep...

how to draw a text in OpenGL view cocoa-objective-c

i need draw a counter onto a OpenGL view. here is my source code for the video frame display cgl_ctx = CGLContextObj ( [[self openGLContext] CGLContextObj]); glEnable(GL_TEXTURE_RECTANGLE_ARB); glGenTextures(1, &_surfaceTexture); glDisable(GL_TEXTURE_RECTANGLE_ARB); GLint swapInt = 1;//100;//1; ...

How can we get kCAOnOrderOut to work?

The Apple documentation claims that the Core Animation action key kCAOnOrderOut has one sole purpose: to animate a layer out of sight when it either becomes hidden or has -removeFromSuperlayer called on it. I'm only referring to the latter case in this question. In practice, when -removeFromSuperlayer is called, the layer is removed imm...

Creating "lookup" values in Core Data

Hi everyone, I have a Core Data entity which needs a gender property. I just need one of two, the standard male or female values. What's the best practice for this in Core Data? In the .NET world with databases I would've created a Gender table, with foreign key in the child table. I'm still getting my head around Core Data right now -...

Nested CALayers not picking up perspective tranform

Hi, I'm trying to make use of CALayers to create a 3D style effect in one of my applications. However, it seems that nested CALayers do not have perspective applied to them. To illustrate with pseudo-code, if I have a layer with perspective applied like so: CATransform3D subLayerTransform = CATransform3DIdentity; /* set perspective */...

Is there a working Cocoa MySQL Xcode project?

Or has this been abandoned? I can't seem to find a modern sample project. I haven't been able to make any the old code I find work. I just want to write a simple Mac app that accesses an external MySQL database that's also involved in a PHP website. ...

How do I add artwork to an iTunes track with obj-c AppScript?

aTrack is an ITReference* object, value is an NSImage* object, initialized via a URL to a jpeg. [[[[[aTrack artworks] data_] set] to:value] send]; I get the following message in GDB: 2010-03-09 16:59:42.860 Sandbox[2260:a0f] Can't pack object of class NSImage (unsupported type): <NSImage 0x10054a440 Size={0, 0} Reps=( I then tried ...

How do I get a textbox in an NSMenu?

I'm pretty sure i've seen this somewhere (not counting the help menu), and I feel like you could just drag one in under ib in leopard. Not that it matters, but it will either go into a dock menu or a service. Thanks ...

Detecting when a space changes in Spaces in Mac OS X

Let's say I want to write a simple Cocoa app to make the Spaces feature of Leopard more useful. I would like to configure each space to have, say, different *screen resolutions *keyboard layouts *volume (for audio) So there are two parts to my question: 1) I suppose there are ways to modify these three things independently of Spaces, r...

NSMutableDictionary in iPhone

After adding the key value pairs in NSMutableDictionary, when i retrive the key/values from it, will that retrived key/value be removed from NSMutableDictionary? or is it stil maintained in NSMutableDictionary? ...