cocoa

Customising an NSTextFieldCell depending on the isEnabled biding of the table column

What I basically trying to achieve is to change the formatting of a cell in a table to blank it out if the cell is not enabled. To define whether a cell in a table column is enabled I've bound using the enabled binding and this is working fine, enabling the cells in some rows of the table and not in others. I have defined a sub-class ...

UITextView with 3 lines automatically scrolls up when I enter <screen capture>

I have a UITextView that i use for typing some text (i have added it with Interface builder) i have made the height 3 font lines high (so in my case the frame height is 47) so i can have 3 lines of text what i want it to do is type until line3 and the go up if i goto line 4 but what it does is whenever i type enter it automatically goe...

NSManagedObjectID into NSData

I found this wonderful NSManagedObjectID. This would be very good for referencing an Entity/NSManagedObject/NSEntityDescription, right? Let's get an ID from an entity: NSEntityDescription *entity = [self newEntity]; NSManagedObjectID *objID = [entity objectID]; So... any idea how to get this objID into a string? Or better: NSData...

How do I use NSMutableArray as a queue?

Hi all, I have NSMutableArray and used it like queue for waiting actions. Example in array: 0: "Do something" 1: "Do something else" 2: "Do something 2" When I used [myarray removeObjectAtIndex:0] the array is not reordering and next time when I use [myarray objectAtIndex:o] the result is nil. How can I put "Do something else" in t...

How do you explicitly animate a CALayer's backgroundColor?

I'm trying to construct a CABasicAnimation to animate the backgroundColor property of a Core Animation CALayer, but I can't figure out how to properly wrap a CGColorRef value to pass to the animation. For example: CGColorSpaceRef rgbColorspace = CGColorSpaceCreateDeviceRGB(); CGFloat values[4] = {1.0, 0.0, 0.0, 1.0}; CGColorRef red =...

Why is movie jumpy when I play simultaneously in 2 Cocoa views?

I have a Cocoa app that has two views. Both of these views are a subclass of QTMovieView. I want to play the same movie in both views (one view is a smaller preview of the larger view). Right now I'm doing: QTMovie *movie = [[QTMovie alloc] initWithFile:path error:nil]; [largeView setMovie:movie]; [smallView setMovie:movie]; Wh...

How to write a string to a text file without deleting/replacing any word in the original file?

In Cocoa, how can I write a string to a text file without replacing the contents of the file, like writing at the end of the file? For example the following code: BOOL written = [data writeToFile:[path stringByAppendingPathComponent:@"conf.txt"] options:NSAtomicWrite error:&error]; The data (string) was written to the text file howev...

NSOutlineView - Auto-expand all nodes

I've got an NSOutlineView bound to an NSTreeController (if that makes a difference), and I'd like to expand every node in my -awakeFromNib(). I'd also like to programatically select the first child of the first node at the same time. These sorts of things are simple with table views, but outlines are not cooperating with me at all. Tha...

@synthesize-ing a C array of structs in Objective-C 2.0

I'm trying to follow a tutorial for a C++ interface in the Mac OS X API (Audio Queue Services), but in a Cocoa (well, actually just Foundation) application (well, actually just a 'tool'). It has a struct that looks like this: static const int kNumberBuffers = 3; // 1 struct AQPlayerState { AudioStreamBas...

NSNumberFormatter: plusSign vs. positivePrefix

The NSNumberFormatter class has plusSign and minusSign properties, but also has positivePrefix and negativePrefix. What is the difference between these two? If I specify both, which one comes first? ...

NSImage - after crop PDF is blurry

I'm trying to crop a NSImage which contains a PDF. When printing I am using NSImage's drawInRect to have it draw only what I need - and this works great. But, now instead I'm trying to create a new NSImage of just the cropped area. I played with it for a while, then found this code on CocoaBuilder: - (NSImage *) imageFromRect: (NSRect)...

Core Data vs SQLite 3

I am already quite familiar with relational databases and have used SQLite (and other databases) in the past. However, Core Data has a certain allure, so I am considering spending some time to learn it for use in my next application. Is there much benefit to using Core Data over SQLite, or vice versa? What are the pros/cons of each? I ...

Cocoa/iPhone: BackgroundColor and Opaque Properties

In Cocoa, specifically the iPhone SDK, the opaque property is described as: If opaque, the drawing operation assumes that the view fills its bounds and can draw more efficiently. The results are unpredictable if opaque and the view doesn’t fill its bounds. Set this property to NO if the view is fully or partially transpar...

How to specify decimal places when formatting NSNumber objects?

I'm using the following piece of Objective-C code to format a NSNumber, and it works fine most of the time, but it doesn't quite do what I want when the NSNumber object holds an integer (no fractional part). UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(80.0f, 90.0f, 225.0f, 40.0f)]; label.backgroundColor = [UIColor clearCo...

How to embed a gem into a RubyCocoa app?

I'd like to embed 2 gems into my RubyCocoa app, so the user doesn't have to install them on the console on him-/herself. But I can't find any information on about how to do that. ...

Use C++ with Cocoa Instead of Objective-C?

Hi. I would like to write applications that use C++ and the Cocoa frameworks because Apple are not making Carbon 64-bit capable. C++ seems to be pretty vanilla in it's implementation on Linux and Windows but on Mac OS X it seems like additional Apple specific pieces of code are required (like an Obj-C wrapper). It also seems that Apple a...

Create an URI for an application

Hey. I want to have an URI for my app. For example something like this: app name:GetIt uri: getit:// Is there an easy way to create one? ...

binding NSTextField to NSNumber

I'm trying to use an NSTextField for integer user input. The text field is bound to an NSNumber property and in the setter method I cleanup the input value (make sure it's an int) and set the property if necessary. I send the willChangeValueForKey: and didChangeValueForKey:, but the UI doesn't update to the new values while that text fie...

[self arguments] in NSScriptCommand

I've created a subclass of NSScriptCommand with wich I get my URI. It works well and with [self directParameter] I get the url. Now I found the great method [self arguments]. if([self isWellFormed] == YES) { NSLog(@"is well formed"); NSDictionary *dic = [self arguments]; NSLog(@"dic = %@", dic); } But dic is empty. =( Also when...

How to access SQL Server from Cocoa (Mac OS X)?

As the question says: How to access Microsoft SQL Server 2005 from Cocoa on Mac OS X 10.5? The database driver should be free if possible, paid solutions can be OK as well. ...